hi, i m working on quiz portal in which different set of question were ask
there are 4 mutiple choice question in which one of the right answer.

i successfuly display the question by selecting using perticular test id(topic)

here is the query:*$rs=mysql_query("SELECT DISTINCT FROM mst_question WHERE test_id ='$tid' ORDER BY RAND()",$cn) or die(mysql_error());**

here also i display the question randomly but the problem is each time when i hit next question button the question repeted.
how i can prevent the reptition of question randomly i want to display one question at once with no repetation.
please if anybody have a solution please comment.
Thankyou any help is appreciated.

Recommended Answers

All 3 Replies

You want to avoid:

  1. overall repetition (i.e. if I connect I don't get your same questions) or
  2. only for the current user (i.e. I never see the same questions anymore, but another user can repeat the path) or
  3. only for the current user's session (i.e. if I logout and come back I can get the same questions again)?

Make a list of all possible questions (list of question numbers or list of addresses). Pick a random entry from the list then delete that entry.

You are using obsolete and dangerous code that has been completetly removed from Php. You need to use PDO with prepared statements. PDO Tutorial

Never ever put variables in a query.
Do not output internal system messages the user. That info is only good to hackers.

Having the test id in a GET variable is a very flawed approach and can be changed by the user at will. At some point a session variable for the test should be set among other things.

It would appear your DB design is flawed as well. There is not enough info here to say much more.

This is an XY Problem which basically means "Help me with my attempted solution" rather than the real problem which is likely "How do I design a quiz application".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.