0

I'm trying to build a quiz script in PHP (most of the presentation logic is done with JS, but the scripts for querying the DB are PHP).

I've managed to setup the script to query the DB for a random question at every run.

But

I have no way of knowing if the user has already answered this question or no, so they can get the same question over and over again.

Also, now that I'm thinking about it - I have no way of knowing if the user went over all the questions in the DB! (Which is the goal of the quiz script in the first place).

How do I go about doing this? (I'm not sure if this is more of a DB question or a general practice question - let me know if SO is not the place).

Tom Granot
  • 1,840
  • 4
  • 22
  • 52
  • 1
    You must be storing user answer in a table for each question. So in the same table may be you can create a another column to store if user has view the question or not. – Deepak Biswal Oct 05 '15 at 08:08
  • have an array of id of question further use "NOT IN " your sql query to get new random questions only – Rohit Kumar Oct 05 '15 at 08:09
  • 1
    So, you decided to go through a quiz without finding out how to actually store the results? - Back to the drawing board I say! (Oh and might consider AJAX?) - You should know with 748 Rep that SO is not a step by step or place where you ask for "How to" questions. – Epodax Oct 05 '15 at 08:09
  • Yeah, but that's the easy way. I want to do something that **does not** require me to query the DB more than once in each quizzing session - resources and precious stuff like that. – Tom Granot Oct 05 '15 at 08:10

1 Answers1

1

well, depending on what you want to do, you have 2 options:

Community
  • 1
  • 1
Luca Filosofi
  • 30,905
  • 9
  • 70
  • 77