Can anyone help me with this code? I cant figure out what is wrong. At the end only the last is displayed can any one help?
Thx Riex
<?php
//query database
if (!$b) {
$b = 0;
}
$db = mysql_connect("127.0.0.1","root");
mysql_select_db("designquiz",$db);
$sql = "select * from anwser where id='$a'";
$result = mysql_query($sql,$db);
$myrow = mysql_fetch_array($result);
if ($submit) {
if ($design != $myrow["anwser"]){
$number = array($b => $a);
//$number[$b] = $a;
$wrong = array($b => $design);
//$wrong[$b] = $design;
$right = array($b => $myrow["anwser"]);
//$right[$b] = $myrow["anwser"];
$b = ($b+1);
}
}
if ($a < 5){
if (!$a){
$a = 1;
}
else{
$a = ($a+1);
}
$sql = "select * from anwser where id='$a'";
$result = mysql_query($sql,$db);
$myrow = mysql_fetch_array($result);
$pic = "d" . $a . ".png";
?>
<body>
<form name="quiz" action="<? echo "$PHP_SELF"; ?>" method="post">
<table align="center">
<tr>
<td><img src="./pic/<?php echo "$pic"?>"><? echo "$pic";?></td>
</tr>
<tr>
<td>
<table align="center">
<tr>
<td align="center">A<br/><input type="radio" name="design" value="A"></td>
<td align="center">B<br/><input type="radio" name="design" value="B"></td>
<?php if ($myrow["type"] == 3) {
echo "<td align=\"center\">C<br/><input type=\"radio\" name=\"design\" value=\"C\"></td>";
}?>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit"><input type="hidden" name="a" value="<? echo "$a"?>"><input type="hidden" name="b" value="<? echo "$b"?>"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php }else{?>
<body>
<table>
<?if ($b == 0){
echo "Congratulations you have gotten a perfect score";
}
else{
$c = count ($number);
echo "$b<br>$c";
print_r($number);
for ($i = 0; $i < $b; $i++) {
$pics = "d" . $number[$i] . "-t.png";
echo "<tr>\n<td><img src=\"pic/thumb/$pics\"></td>\n<td><p><b>Your Answer:</b> $wrong[$i]</p></br>
<p><b>Right Answer:</b> $right[$i]</p></td>\n</tr>\n\n";
}
}
}
?>
</body>
</html>