random select

From: Date: Tue, 17 Dec 2002 10:46:12 +0000
Subject: random select
Groups: php.db 
Request: Send a blank email to php-db+get-24215@lists.php.net to get a copy of this message
Bruce Levick - VivamotionI was curious as to what is the best way to select a random row from a table in my database. I have currently five rows and will be expanding on that as well. I have tried this code. ######################################################################## //retrieve random row <?php $rndm = mysql_query("SELECT * FROM Illustrations ORDER BY RAND() LIMIT 1"); if (!$rndm) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } ?> ###################################################################### output random row <?php print "<b>$rndm[titletext]</b>\n"; ?> ###################################################################### but am not getting anything when output with PHP in a browser. I am working off localhost on a WINXP machine. PHP 4.2.2. Cheers

« previous php.db (#24215) next »