[prev in list] [next in list] [prev in thread] [next in thread]
List: php-db
Subject: Re: [PHP-DB] Random question selection in PHP w/ MySQL backend.
From: "John Pickett" <xtremist () xmission ! com>
Date: 2001-07-31 20:47:28
[Download RAW message or body]
Adam,
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
started... Cheers!
My 2 ¢
John Pickett
http://www.bvstudios.com/
Co-Author: Inside Dreamweaver 4
http://www.amazon.com/exec/obidos/ASIN/0735710848/xtremist
----- Original Message -----
From: "Adam Lundrigan" <ceo@vpu-virtual.com>
To: <php-db@lists.php.net>
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.
Any suggestions??
Thanks in advance,
-Adam Lundrigan
CEO, VPU
http://www.vpu-virtual.com/
ICQ # 73617446
ceo@vpu-virtual.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic