I want to extract from database 3 different checkbox values and compare them with the value of 3 checkboxes from the web page. How can I do that? Below I wrote the script with comments.
<?php
require_once ("config.php");
$corect = 0;
$incorect = 0;
function select() {
$questionsq=mysql_query("SELECT * FROM questions order by rand() LIMIT 1");
while($r=mysql_fetch_array($questionsq)){
echo '<br><br><div class="question">'.$r["question"].'</div>';
echo'<br /><br />';
echo 'a) '.$r["answer1"].'<br /><br />';
echo 'b) '.$r["answer2"].'<br /><br />';
echo 'b) '.$r["answer3"].'<br /><br />';
//echo '<img href="" src="imagini/'.$r["image"].'" width="250" height="200">';
echo'<br /><br />';
$val1 = $r['option1']; // here I think that I have to assing to a variable the option1 value from database for comparison
$val2 = $r['option2'];
$val3 = $r['option3'];
}
}
$IsChecked1 = (isset($_POST['check1'])) ? 1 : 0; // check1,check2,check3 are checkboxes from the web page
$IsChecked2 = (isset($_POST['check2'])) ? 1 : 0;
$IsChecked3 = (isset($_POST['check3'])) ? 1 : 0;
if($val1 == $IsChecked1 && $val2 == $IsChecked2 && $val3 == $IsChecked3)
$correct++;
?>
Aucun commentaire:
Enregistrer un commentaire