Posted by needaticker on 09/30/03 11:26
This pretty much does what I need it to but it adds some code in the
result. (I mean instead of just showing the "random entry", it shows
"Array ( [field] => random entry )". It would be great if I could get
rid of all the other stuff. Here's my code so far. Can anyone tidy up
my result to get it to do what I want it to?
Thanks
<?php
$username="username";
$password="password";
$database="database";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$randgetq=mysql_query("SELECT * FROM tablename ORDER BY RAND() LIMIT
1");
if (!$randgetresults=mysql_fetch_array($randgetq, MYSQL_ASSOC))
{
echo "Sorry no entries";
}
else
{
print_r($randgetresults);
}
mysql_close();
?>
[Back to original message]
|