Your data tables are awful. You need one table for questions and another table for answers. Each entry in the answers table refers back to a question in the questions table and has a flag indicating whether it is the correct answer.
So, the QUESTIONS table has the following fields:
QUESTION_ID
QUESTION_TEXT
QUESTION_TYPE -- Like MC, TF, FIB ...
The ANSWERS table has the following fields:
ANSWER_ID
QUESTION_ID
ANSWER_TEXT
IS_CORRECT
Makes your life infinitely easier and obviates the raison d'etre for this question.
I'm trying to code a multiple choice quiz for my fellow students -and primarily to aid my own learning- and so I'm creating a multiple choice web-based quiz using PHP (5.2.08) and MySQL (5.0.32)
The questions table is:
+----------+--------------+------+-----+---------+----------------+|Field|Type|Null|Key|Default|Extra|+----------+--------------+------+-----+---------+----------------+| id |int(6)| NO | PRI | NULL | auto_increment || question | varchar(200)| NO || NULL ||| correct | varchar(80)| NO || NULL ||| wrong1 | varchar(80)| NO || NULL ||| wrong2 | varchar(80)| NO || NULL ||| wrong3 | varchar(80)| NO || NULL ||+----------+--------------+------+-----+---------+----------------+
Sample print_r($questions) output for one question:
Array([0]=>Array([id]=>1[question]=>Whatis the correct pipeline pressure forNitrousOxide(<abbr title="Nitrous Oxide.">N<span class="chem-notation">2</span>O</abbr>)?[answers]=>Array([0]=>Array([correct]=>1[answer]=>60<abbr title="Pounds per square inch">PSI</abbr>.)[1]=>Array([correct]=>0[answer]=>45<abbr title="Pounds per square inch">PSI</abbr>.)[2]=>Array([correct]=>0[answer]=>30<abbr title="Pounds per square inch">PSI</