I'm making a quiz system and tried a different way of taking the variables and the values from MySQL.
$question = mysql_query("SELECT * FROM `questions`");
$stat = mysql_fetch_assoc($question);
$num = mysql_num_rows($question);
$questionid = 0;
for($i=0;$i<=$num;$i++)
{
$question = mysql_query("SELECT * FROM `questions` WHERE `id`='$i'");
$stat = mysql_fetch_assoc($question);
//if($stat['answer'] == null
echo $stat['question'] . '<br />';
echo '<input type="radio" name="' . $i .'" value="' . $questionid . '" />' . $stat['answer1'] . '<br />';
echo '<input type="radio" name="$i" value"$questionid" />' . $stat['answer2'] . '<br />';
echo '<input type="radio" name="$i" value"$questionid" />' . $stat['answer3'] . '<br />';
echo '<input type="radio" name="$i" value"$questionid" />' . $stat['answer4'] . '<br />';
$questionid++;
}
Now, I want to let the person choose the correct answer but when I try to select answer in question 1, and then in question 2, it won't let me probably because the radios have the same name - I don't know how to make it possible for the student to select one answer in each question and also how to get his choice (to store it in a variable and check if the answer is correct).