A
Anonymous
Guest
i have a quiz results page which checks each answer and echos the right answer if its wrong etc.
i have ten of these and then at the end i just want it to display the final score and a link but it always place it above the 10th echo answer and i have no idea on why its doing it and ive tried everything i can think of.
heres my code...
the whole page follows the same pattern till the end but when viewed in a browser the bottom lines appear above the 10th statement
any ideas? cheers for any help
i have ten of these and then at the end i just want it to display the final score and a link but it always place it above the 10th echo answer and i have no idea on why its doing it and ive tried everything i can think of.
heres my code...
PHP:
<?php $queryq8 = "Select * from natquiz WHERE QNO ='$randomqno8'";
$resultq8 = mysql_query($queryq8);
while ($row = mysql_fetch_array($resultq8)) {
$qno8 = $row['QNO'];
$question8 = $row['Question'];
$ansa8 = $row['AnsA'];
$ansb8 = $row['AnsB'];
$ansc8 = $row['AnsC'];
$ansd8 = $row['AnsD'];
$ans8 = $row['Answer'];
}
if ($question8result == $ans8) {
echo "<table border=0 width=100%>";
echo "<tr><th><h3 align=left><img src=\"resources/quizcorrect.jpg\" />You answered Question: 8 {$question8result} - This is Correct! </th></tr>\r\n";
$score++;
} else {
echo "<table border=0 width=100% bgcolor=c0c0c0>";
echo "<tr><th><h3 align=left><img src=\"resources/quizincorrect.jpg\" />You answered Question: 8 {$question8result} - This is Incorrect, The Correct answer is {$ans8}</th></tr>\r\n";
}
?>
<br>
<?php $queryq9 = "Select * from natquiz WHERE QNO ='$randomqno9'";
$resultq9 = mysql_query($queryq9);
while ($row = mysql_fetch_array($resultq9)) {
$qno9 = $row['QNO'];
$question9 = $row['Question'];
$ansa9 = $row['AnsA'];
$ansb9 = $row['AnsB'];
$ansc9 = $row['AnsC'];
$ansd9 = $row['AnsD'];
$ans9 = $row['Answer'];
}
if ($question9result == $ans9) {
echo "<table border=0 width=100%>";
echo "<tr><th><h3 align=left><img src=\"resources/quizcorrect.jpg\" />You answered Question: 9 {$question9result} - This is Correct! </th></tr>\r\n";
$score++;
} else {
echo "<table border=0 width=100% bgcolor=c0c0c0>";
echo "<tr><th><h3 align=left><img src=\"resources/quizincorrect.jpg\" />You answered Question: 9 {$question9result} - This is Incorrect, The Correct answer is {$ans9}</th></tr>\r\n";
}
?>
<br>
<?php
$queryq10 = "Select * from natquiz WHERE QNO ='$randomqno10'";
$resultq10 = mysql_query($queryq10);
while ($row = mysql_fetch_array($resultq10)) {
$qno10 = $row['QNO'];
$question10 = $row['Question'];
$ansa10 = $row['AnsA'];
$ansb10 = $row['AnsB'];
$ansc10 = $row['AnsC'];
$ansd10 = $row['AnsD'];
$ans10 = $row['Answer'];
}
if ($question10result == $ans10) {
echo "<table border=0 width=100%>";
echo "<tr><th><h3 align=left><img src=\"resources/quizcorrect.jpg\" />You answered Question: 10 {$question10result} - This is Correct! </th></tr>\r\n";
$score++;
} else {
echo "<table border=0 width=100% bgcolor=c0c0c0>";
echo "<tr><th><h3 align=left><img src=\"resources/quizincorrect.jpg\" />You answered Question: 10 {$question10result} - This is Incorrect, The Correct answer is {$ans10}</th></tr>\r\n";
}
?>
<br>
<h3 align="center">You Got <?php echo $score ?> Questions Correct!</h3>
<h2 align="center">Save Quiz Score? <a href="resources/setquizcookie.php?score=<?php echo $score ?>">Click Here</a></h2>
</body>
the whole page follows the same pattern till the end but when viewed in a browser the bottom lines appear above the 10th statement
any ideas? cheers for any help