Forum Moderators: coopster

Message Too Old, No Replies

Developing a quiz - populating with rand questions

How to make sure that same quest will not dupe?

         

henry0

8:46 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need some logic guidance
I will let the “admin” creating and Db storing as many Q & A as the admin could think of
Next I will dynamically populate a form with randomly selected Q & A
But I cannot set my mind on a solution that will disallow any dupe
I rather not test for a condition one at a time for each row from the very top of the form.
The form could have up to 20 rows
Any suggestion?

willybfriendly

9:57 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$q = "SELECT 'id" FROM questions";
$result = mysql_query($q);

$questions = mysql_fetch_array($result);
shuffle($questions);

//now use a loop to pull the desired number of random questions to fill the form.

etc.;

henry0

10:15 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah Yes, thanks shuffle()
and I will build the form within the loop

let's code!