Wednesday, May 9, 2012

PHP - Select radio button using mysql after submit form

            <?php
       
                echo "<li id=\"li_17\">";
                echo "<label class=\"description\" for=\"element_17\">Question :</label>";
                    $row = mysql_query("SELECT * FROM quiz_lcd where datesent = CURDATE()");
            while($ib_row = mysql_fetch_array($row))
            {
                echo $ib_row['question'];   
                        echo "</li>";       
                        echo "<li id=\"li_18\">";
                        echo "<label class=\"description\" for=\"element_18\"></label>";
                        echo "<span>";
           
            // Radio Button for Option1
                    if ($ib_row['option1'] == $ib_row['correctanswer'])
                        {    echo "<input id=\"element_18_1\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"1\"  checked/>";
                        }
                    else
                        {
                        echo "<input id=\"element_18_1\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"1\" />";
                        }
                    echo "<label class=\"choice\" for=\"element_18_1\">";
                     echo $ib_row['option1'];
                    echo "</label>";       

            // Radio Button for Option2        
                    if ($ib_row['option2'] == $ib_row['correctanswer'])
                        {    echo "<input id=\"element_18_2\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"2\"  checked/>";
                        }
                    else
                        {
                        echo "<input id=\"element_18_2\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"2\"  />";
                        }
                    echo "<label class=\"choice\" for=\"element_18_2\">";
                     echo $ib_row['option2'];
                    echo "</label>";           
           
            // Radio Button for Option3
                    if ($ib_row['option3'] == $ib_row['correctanswer'])
                        {    echo "<input id=\"element_18_4\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"4\"  checked/>";
                        }
                    else
                        {
                        echo "<input id=\"element_18_4\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"4\" />";
                        }
                    echo "<label class=\"choice\" for=\"element_18_3\">";
                     echo $ib_row['option3'];
                    echo "</label>";           
               
            // Radio Button for Option4    
                    if ($ib_row['option4'] == $ib_row['correctanswer'])
                        {
                            echo "<input id=\"element_18_4\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"4\"  checked/>";
                        }
                    else
                        {
                        echo "<input id=\"element_18_4\" name=\"element_18\" class=\"element radio\" type=\"radio\" value=\"4\" />";
                        }
                        echo "<label class=\"choice\" for=\"element_18_3\">";
                        echo $ib_row['option4'];
                        echo "</label>";
            }
                       
            ?>

Tuesday, May 8, 2012

PHP - Insert values from radio button values into mysql


$email=$_POST['email_id'];
 $option=$_POST['optn'];

 // Insert value from radio button value into mysql
while($ib_row = mysql_fetch_array($row))
{
  echo $email;
echo "</br>";
echo $option;
echo "</br>";

switch($option)
{
case "option1":
$answer_submit =  $ib_row['option1'];
echo $answer_submit;
break;
case "option2":
$answer_submit =  $ib_row['option2'];
echo $answer_submit;
break;
  case "option3":
$answer_submit =  $ib_row['option3'];
echo $answer_submit;
break;
case "option4":
$answer_submit =  $ib_row['option4'];
echo $answer_submit;
break;
}

$quiz_id = $ib_row['quizid'];
}

 mysql_query("INSERT INTO quiz_response_lcd VALUES ('$quiz_id', '$email', '$answer_submit', CURDATE())");

PHP - Dropdown contains all value from mysql


<?php
require('db/db_open.php');
$row = mysql_query("SELECT * FROM quiz_lcd where datesent = CURDATE()");

 // Insert value from radio button value into mysql
while($ib_row = mysql_fetch_array($row))
{
echo "<option value=\"1\" >" . $ib_row['option1'] . "</option>";
echo "<option value=\"2\" >" . $ib_row['option2'] . "</option>";
echo "<option value=\"3\" >" . $ib_row['option3'] . "</option>";
echo "<option value=\"4\" >" . $ib_row['option4'] . "</option>";

}
?>

Wednesday, August 17, 2011

Folder to manage php files

Folder to manage php files under wamp server

Make Folders to manage php files - css, db, images & includes

Steps:
1.      Go to  'c:\wamp\www\ folder 
2.      Make all folder css, db, images & includes (all should be in small characters)



‘css’ – Save all css files

‘db’ – Save all database files

‘images’ – Save all images files

‘includes’ - Save header.php, footer.php, left.php, right.php & center.php files



WAMP SERVER Analysis

WAMP SERVER Analysis

main folder -  'www'  (new webpages)

If you have installed into default location "C:\wamp" and all websites pages & folder will be installed under main 'www' folder.... and main file is index.php which works with php webpage.



Folder -  'www' (Existing webpages)

If you have already prepared some php webpages and you want to installed into your local computer then go to path 'c:\wamp\www\' and copy all php files into this 'www' folder and try to run php webpages on browser after running wamserver


Adjust CSS Template

Adjust CSS Template as per your requirement - Header, Footer, Left, Right & Center

Free CSS template

Free CSS template