[Solved] Storing data, in arranged sequence into mysql


Without your actual database schema/more information it is difficult to give you the best advice possible.

Add a field to the table radio so that it looks something like this:

RADIO (*user*, *questionId*, Option1, Option2, Option3)

(due to stack overflow formatting stars represent the primary key(s))

where questionID is a foreign key that references QUESTION(id). If you don’t have an id field in your question table add that too.

Then when you display the question to the user, save the question ID as a hidden input field inside the tag like so:

<input type="hidden" name="questionId" value="".$data["id']."' />

When the form is submitted you will have the question ID available in your $_POST array at $_POST['questionId']

Then you can modify your INSERT query to insert the question ID as well and simply not display it when you display the data later.

As for displaying the correct answers to the students, you will need to store the correct answer in your table somehow. One way would be to add a field to your question table indicating which of the options is the correct answer, I.E. a TINYINT(1) which will contain a 1, 2, or 3 depending on which answer is correct. You can then use that to generate a page with the correct answer to the question.

6

solved Storing data, in arranged sequence into mysql