random row
| From: | John Taylor-Johnston | Date: | Wed, 16 Nov 2005 04:17:06 +0000 |
| Subject: | random row | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-225893@lists.php.net to get a copy of this message | ||
My question is simnple. I want to randomly select a row in a mysql table. I have a primary id.
<?php
$server = "localhost";
$user = "foo";
$pass = "foo";
$db="foo_db";
$table="foo_table";
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$sql = ??;
$news = mysql_query($sql) or die(print "<font color=red>".mysql_error()."</font>");
while ($mydata = mysql_fetch_object($news))
{
??
}
?>