RE: [PHP] WHERE problem
| From: | Jay Blanchard | Date: | Mon, 19 Feb 2007 21:23:47 +0000 |
| Subject: | RE: [PHP] WHERE problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-249051@lists.php.net to get a copy of this message | ||
[snip]
// Get randomized!... the moderated way...
$randi = mt_rand(1, $max-1);
$q = "SELECT text FROM fortunes WHERE index = '$randi'";
$choose = mysql_query($q);
$chosen1 = mysql_fetch_array($choose);
[/snip]
Put the random statement in the query
SELECT foo FROM bar ORDER BY RAND() LIMIT 1