I m working on a quiz, obviously for the first time …
I have created a database like:
ID Question OPTION1 OPTION2 OPTION3 Correct answer.
Currently i have 20 questions with options and correct answer.
I want to display only 10 questions randomly out of 20, each time without repetition.
The quiz be like, in the div one question will show at a time. Once a question is submitted, another will come into its place. Also, i dont want to store users answer. It will be compared regularly with each answer and total will be displayed at the end of quiz.
But i dont know how to achieve. I need some idea to achieve this please.
SELECT question FROM table_name
ORDER BY RAND()
LIMIT 10
This isn’t the most performant way, but by far the easiest to work with and understand, which I think you are more concerned about.
However, this will not resolve the other issues, which is having a new question drop into place every time a question is answered. For that, you will need to keep track of the question ID’s that are being displayed, that were already displayed, and were answered.