I am trying to make an online examination script in PHP and am stuck at the results page.
The actual answers here are stored in a 2D array called 'ans' in the format:
Say for question 1 the answers are options 2 and 4, then it would be stored as
If for the second question the answers are option 1 ,3 and 4 then
21 23 24
So the whole array would look like:
21 23 24
The options are check boxes with ID's and names similar to the way it is stored in the array.
I am using the following snippet of code to check through the answers:
for($i=1; $i<=$noq2d; $i++)
for($j=1; $j<7; $j++)
if($_POST[$z] && $nomore==false && in_array($z,$ans[$i]))
echo('Number of correct answers: '.$cq);
However, it is giving 0 as the result under any and every situation. The full code of the result page is here: http://adeydas.com/dump/result.phps
Any help will be highly appreciated!