Re: Random Record Retrieval

From: Date: Sat, 22 May 2004 22:57:01 +0000
Subject: Re: Random Record Retrieval
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-186773@lists.php.net to get a copy of this message
How about rand() on your ID column. http://www.php.net/manual/en/function.rand.php >>How's that for alliteration in a subject line? >> >>Got a simple MySQL table that contains records which are made up of only >>three fields - ID, quote and author. These are "inspirational" quotes that >>I want to appear at the bottom of the pages of my website. I want them to >>come up randomly with every page load. I've posted this on a MySQL board to >>see if there's a MySQL command to make things simple. But, I thought about >>building a random number generator in PHP that selects a random number out >>of the total number of records in the table, saves it into a variable and >>then have MySQL retrieve that ID. Is this the way to go or is there >>something simpler. And, if this is the best way to go, unfortunately I >>don't know how to write a random number generator in PHP so would >>appreciate any help. >> >>Thanx in advance, >>Robb

« previous php.general (#186773) next »