Ok, ive been pondering how to solve this problem all morning and still cant come up with an answer. Basicly my problem is this. I am working on a online test thingy for teachers at a local school. Basicaly most of the teachers arnt all that computer minded, ive decided to go with a easy system for them to create tests.
Its just a text box, line one is the question, line two are the answers separated by commas etc.
an example....
question one goes here
answer1, answer2@, answer3
question two goes here
answer1, answer2, answer3@, answer 4
(they can have as many or as little answers as they want. The @ is after the real answer)
So ive created a code that takes this info from a sql database, breakes up each line into an array, then each answer line into another array.. example
$line[1] = question one goes here
$line[2] = answer1, answer2@, answer3
$line[3] = question two goes here
$line[4] = answer1, answer2, answer3@, answer 4
$answer[1] = answer1
$answer[2] = answer2
$answer[3] = answer3
(you get the idea hope fully..)
So it generates the test page. Each question has its group of answers which are given an option button. The value of the option button is the answer and the name is the question number.
Here is my problem. When they go and hit submit, I need some way to check these answers. Ive written very similar code to the test page generation code only instead of echo'ing the data to a page it checks to see which one is the answer. Then if i could only go do this
$question1 = $answer
$question1 being the name of the option field they selected and $answer being the answer the check page got. But I need some way to change the ending of $question1 to $question2 then $question3 so i can compaire it in a while loop untill every question has been checked.
AHhh im soo confused please help!