how to display the randomly selsected questions from a database one at a time in jsp like in online quiz.please help me

Recommended Answers

All 3 Replies

Solution depends on many things, but considering that for example you have situation where you have fixed numbers of question for quiz like 10 and larger number of questions to choose from I would query database for question IDs, run random generator between 0 and total-1 of question and pick 10 random IDs. Another query to database to retrieve all data related to selected IDs, store them in bean, pass it through session and job is done.

Solution depends on many things, but considering that for example you have situation where you have fixed numbers of question for quiz like 10 and larger number of questions to choose from I would query database for question IDs, run random generator between 0 and total-1 of question and pick 10 random IDs. Another query to database to retrieve all data related to selected IDs, store them in bean, pass it through session and job is done.

i didn't get you.actually i retrieved the random questions from the database.but the problem is they r displaying all at a time.i want to display one question at a time and when the user clicks the submit button next question is displayed and so on.can u please elaborate what u want me to do

so retrieve 1 question only, not all of them :)
1) get a random number to indicate the question to get
2) use that to retrieve the question and only the question
3) show the question

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.