I'm trying to develop an online quiz system using PHP/MySQL/Apache (big surpirse there).
One page can have up to 50 questions, each question has 4 radio buttons as answers, named like this:
a_1_1, a_1_2, a_1_3, a_1_4, a_2_1, etc, etc.
The question is, how do I pass all those answers into an array so I can easily compare the answers?
I want an array that looks like this
Where $i is the question number and $a is the correct answer.
This is how I'm going to compare them:
Thanks
One page can have up to 50 questions, each question has 4 radio buttons as answers, named like this:
a_1_1, a_1_2, a_1_3, a_1_4, a_2_1, etc, etc.
The question is, how do I pass all those answers into an array so I can easily compare the answers?
I want an array that looks like this
Code:
Answers[ 1 => 1, 2=>4, 3=>1....$i=>$a]
This is how I'm going to compare them:
Code:
for($i=0; $i<$total; $i++)
{ echo $i;
$res = mysql_query("Select CorrectA, Qnum from Questions where Qnum = $i");
$r = mysql_fetch_array($res);
$correct= $r['CorrectA'];
$Qnum = $r['Qnum'];
$correct_answers[$Qnum]= $correct;
if ($answers[$i]==$correct_answers[$i])
{
echo "CORRECT";
}
}