If you are using MySQL try looking at this page for the function rand():


Here's a little overview of what it says:

"In MySQL Version 3.23, you can, however, do: SELECT * FROM table_name ORDER
BY RAND() This is useful to get a random sample of a set SELECT * FROM
table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000. Note that a
RAND() in a WHERE clause will be re-evaluated every time the WHERE is
executed. RAND() is not meant to be a perfect random generator, but instead
a fast way to generate ad hoc random numbers that will be portable between
platforms for the same MySQL version. "



Nobody will ever win the Battle of the Sexes. There's just too much
fraternizing with the enemy. - Henry Kissinger

> From: Jule <[EMAIL PROTECTED]>
> Date: Sat, 18 May 2002 17:41:59 -0400
> Subject: [PHP] random order by id
> Hey guys,
> i have a db and a table with id and questions
> now i want these questions to be listed in a random order, is there a way
> to format my SQL query or do i need some PHP work to?
> i can ofcourse select a random one, that's no problem, but how do i make
> sure that that one does not get chosen again. and that after it has printed
> all the records it stops
> any ideas?
> Jule
> -- 
> |\/\__________________________/\/|
> |   Jule Slootbeek         |
> |   [EMAIL PROTECTED]     |
> |   http://blindtheory.cjb.net     |
> |   __________________________     |
> |/\/                  \/\|
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to