note 96465 deleted from function.rand by danbrown
| From: | danbrown@php.net | Date: | Mon, 01 Mar 2010 16:00:42 +0000 |
| Subject: | note 96465 deleted from function.rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166497@lists.php.net to get a copy of this message | ||
Note Submitter: bohacpetr AT bohyn DOT cz
----
To mike at marylandwebsites dot net:
It's not nice pice of code you have sent. You shoud better try something like this:
<?php
$SQL = <<< EOT
SELECT *
FROM
(SELECT *
FROM HIGHLIGHTS
ORDER BY highlight_id DESC
LIMIT 5) AS t1
ORDER BY RAND()
LIMIT 1
EOT;
$result = mysql_query( $SQL );
while( $row = mysql_fetch_assoc( $result ) ) {
// ...
}
?>