php-db | 2002122
Date: 12/17/02
- Next message: Chris Jewell: "[PHP-DB] Getting database output into another frame in another window"
- Previous message: Daevid Vincent: "RE: [PHP-DB] How can I use PHP to duplicate a mysql template database? [hack]"
- Next in thread: Jason Wong: "Re: [PHP-DB] random select"
- Reply: Jason Wong: "Re: [PHP-DB] random select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Chris Jewell: "[PHP-DB] Getting database output into another frame in another window"
- Previous message: Daevid Vincent: "RE: [PHP-DB] How can I use PHP to duplicate a mysql template database? [hack]"
- Next in thread: Jason Wong: "Re: [PHP-DB] random select"
- Reply: Jason Wong: "Re: [PHP-DB] random select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

