I'm what I would call a novice to PHP and databases in general, however if I
had to do what you're doing, I might do the following...
Add a field to the table that contains your questions called "displayed" and
have it be an enum of Yes/No True/False, etc... In your script, you'd then
query for all the questions that haven't already been displayed. Then get a
random one of those (plenty of randomizing functions in PHP I believe).
Display it, mark it as displayed in the db... Next time, it won't even get
returned in the query. I don't know if you have to do this on a per-user
basis or what. If so, you will probably have to create a session table and
keep track of the questions each user has viewed... Hope this gets you
My 2 ¢
Co-Author: Inside Dreamweaver 4
----- Original Message -----
From: "Adam Lundrigan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 31, 2001 2:32 PM
Subject: [PHP-DB] Random question selection in PHP w/ MySQL backend.
I'm having a bit of trouble creating a random question selector. I'm using
PHP 4.0.6 and MySQL 3.23.36 on Windows 98 SE.
I've tried several different solutions, but none work at all.
What i need to do is select 10 questions from a database (db: vpt, table:
questions), and make sure that the same question doesn't appear twice. The
questions need to appear in a random order each time the script is loaded.
It sounds simple enough, but i just can't seem to get it to work.
Thanks in advance,
ICQ # 73617446
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]