ORDER BY RAND()....
From: Payne (payne_at_magidesign.com)
Date: 10/29/03
- Next message: Gerard Samuel: "gzcompress/gzdeflate default compression level?"
- Previous message: Alain Dhaene: "Re: [PHP] redirect"
- Next in thread: Gerard Samuel: "Re: [PHP] ORDER BY RAND()...."
- Reply: Gerard Samuel: "Re: [PHP] ORDER BY RAND()...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Oct 2003 14:24:04 -0500 To: php-general@lists.php.net
Hi,
I have been working on a simple PHP script that called to a mysql
database, where I do the following....
SELECT url FROM sponsors ORDER BY RAND();
When I do a refresh I keep getting the same url, I have test this sql
statement in mysql and it works great. I think my problem is this...
Here is my php script....
<?
$db = mysql_connect("69.15.40.130","cepayne","death");
mysql_select_db("links",$db);
$result = mysql_query("SELECT url FROM sponsors order by
rand() LIMIT 1", $db);
if ($myrow = mysql_fetch_array($result)) {
echo"<table width='500' border='0' cellspacing='0'
cellpadding='0'>";
do {
printf("<tr><td>%s</td></tr>\n",$myrow[url]);
} while ($myrow = mysql_fetch_array($result));
} else {
echo "Sorry, no message of day today";
}
echo "</table>"
?>
I know that what I have got here must be the problem because this code
was use to get mutli line of results. Is there a way to retype this so
that I only get the one statement I need?
Payne
- Next message: Gerard Samuel: "gzcompress/gzdeflate default compression level?"
- Previous message: Alain Dhaene: "Re: [PHP] redirect"
- Next in thread: Gerard Samuel: "Re: [PHP] ORDER BY RAND()...."
- Reply: Gerard Samuel: "Re: [PHP] ORDER BY RAND()...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|