|
Posted by Rik on 12/18/02 11:51
Garry wrote:
> I am trying to create a multiple choice test based on a MySQL
> database in PHP and presenting just one question at a time for the
> user to read and slect the correct answer. If the correct answer is
> selected a congratulatory message is displayed and the correct count
> is incremented. If an incorrect answer is chosen, then display the
> correct answer. In both cases increment the question count and move
> on to the next question.
>
> The main reason for storing the questions in MySQL is to create a
> generic test wrapper that can be used for any kind of Multiple choice
> test.
>
>
> Thank you if you have any idea on how I can process just onbe
> (Row/Question) at a time.
So, your problem isn't that you want to process the results individually,
you want only 1 row from the database. Assuming you want to let them see
only one question, and then submit a form to the next page?
Possible solutions:
- add a field called 'question_number" or something, and query 'SELECT
question, answer FROM table WHERE questionnumber = the variable. The
variable could be increased after every answer, possibly using a GET or POST
variable.
- You could use a LIMIT $start, 1 at the end of your query, where $start is
also incremented after every question, again a GET or POST variable seems
logical.
If you want to use MySQL, I would suggest reading some tutorials on SQL /
query-building. If you want only one row, the SQL should give you only one,
don't try to let PHP sort it out.
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|