note 42771 added to function.rand
| From: | php-general at lists dot php dot net | Date: | Fri, 28 May 2004 14:32:52 +0000 |
| Subject: | note 42771 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70243@lists.php.net to get a copy of this message | ||
If mysql 3.23.* is having problems getting a random item. Try the following.
$myrand = RAND();
$query="SELECT * from table ORDER by RAND($myrand) LIMIT 1"
I ran in to problems after realising my server was running a different version than I was testing
locally. But after much searching (and trying timestamps with dubious results), I came up with this
simple solution that sorted it.
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42771
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42771&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42771&report=yes
Search -- http://master.php.net/manage/user-notes.php