at the moment i have the following code for my quiz
this bit gets the question
then echos it out, the next bit marks itPHP Code:<?php
$queryq3 = "SELECT QNO, Question, AnsA, AnsB, AnsC, AnsD, Answer FROM ip4quiz WHERE QNO ='3'";
$resultq3 = mysql_query($queryq3);
while ($row = mysql_fetch_array($resultq3)) {
$questionno3 = $row['QNO'];
$question3 = $row['Question'];
$ansa3 = $row['AnsA'];
$ansb3 = $row['AnsB'];
$ansc3 = $row['AnsC'];
$ansd3 = $row['AnsD'];
}
?>
how can i make it pick from a list of questions at random instead of being told QNO = etc. my attempts have failed so far, any suggestions?PHP Code:<?php $queryq2 = "Select * from ip4quiz WHERE QNO ='2'";
$resultq2 = mysql_query($queryq2);
while ($row = mysql_fetch_array($resultq2)) {
$qno2 = $row['QNO'];
$question2 = $row['Question'];
$ansa2 = $row['AnsA'];
$ansb2 = $row['AnsB'];
$ansc2 = $row['AnsC'];
$ansd2 = $row['AnsD'];
$ans2 = $row['Answer'];
}
if ($question2result == $ans2) {
echo "<table border=0 width=100%>";
echo "<tr><th><h3 align=left><img src=\"../images/quiz/quizcorrect.jpg\" />You answered Question: {$qno2} {$question2result} - This is Correct! </th></tr>\r\n";
$score++;
} else {
echo "<table border=0 width=100% bgcolor=003366>";
echo "<tr><th><h3 align=left><img src=\"../images/quiz/quizinincorrect.jpg\" />You answered Question: {$qno2} {$question2result} - This is Incorrect, The Correct answer is {$ans2}</th></tr>\r\n";
}
?>


Reply With Quote
Bookmarks