RE: [PHP] random order by id
| From: | David Freeman | Date: | Sat, 18 May 2002 22:56:44 +0000 |
| Subject: | RE: [PHP] random order by id | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98301@lists.php.net to get a copy of this message | ||
> 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?
It's best achieved in sql:
SELECT ID, Question FROM Questions WHERE Some = Condition ORDER BY
RAND() LIMIT 10
Will get you up to ten randomised questions based on your 'where'
condition.
CYA, Dave