:mad:
I'm currently creating a quiz program that radomly generates questions from a table in mysql........right now I have to php forms.
takeTest.php.....
<html>
<head>
<title>Test Week 13 CIS32</title>
</head>
<body bgcolor = "yellow">
<center>
<?
$link = mysql_connect("localhost", "web26", "web9660!", "sere1")
or die("Error ".mysql_errno().": ".mysql_error()."<br>\nThe SQL sent was: $sql");
print("Connected successfully");
mysql_select_db("sere1", $link);
$sql = "Select * from quiz1 order by rand() limit 0,1";
$result = mysql_query($sql) or die(mysql_error());
$num_results= mysql_num_rows($result);
echo "<form method=post action='grade.php'>";
echo "<table border=1>";
while ($row = mysql_fetch_array($result))
{
$id = $row;
$question = $row["question"];
$ans1 = $row["ans1"];
$ans2 = $row["ans2"];
$answer = $row["answer"];
echo "<tr><td colspan=3><br><b>$question</b></td></tr>";
echo "<tr><td>$ans1 <input type=radio name='$id' value='$ans1'></td><td>$ans2 <input type=radio name='$id' value='$ans2'></td></tr>";
}
echo "</table>";
echo "<input type='submit' value='Get Grade' name='submit'>";
echo "</form>";
?>
</center>
</body>
</html>
grade.php....
<?
$id = $_POST;
$score = 0;
while ($result = mysql_fetch_array($result)){
$answer = $result["answer"];
$id = $result["id"];
if ($$id == $answer)
{
$score = $score + 10;
}
}
echo "$score";
?>
I can't for the life of me figure out why I'm getting this error....any help would be a godsend.
BTW...There's only one question in the table right now...