September 21st, 2000, 07:28 AM
I am trying to select a randon entry from mysql. Anyway - My version of mysql doesn't have the built in rand() function, so I am using PHP's. Anyway - I wrote the following function...
$rand = rand(10,202000);
$query = "SELECT *, $rand as random FROM guide_rotater ORDER BY random LIMIT 1";
$result = mysql_query($query);
$this = mysql_fetch_object($result);
print "<b>$this->title</b><p>$this->description<p><a href="$this->url"><b>Read the guide</b></a>";
Anyway - it works, the only problem is that it uses the same $rand number for all of them so it isn't random
I can't think of a way to do this using php's rand function. Can someone please help - I am sure its something simple, but I donno what the hell it is.
September 21st, 2000, 08:17 AM