I actually wrote one for my old website (
www.vibewave.com) that retrieves a random quote...
Here:
PHP Code:
//get a random quote... using arrays.
//Be sure to connect to the db.
$query1 = "SELECT * FROM quotes";
$result1 = mysql_query($query1);
while ($row1 = mysql_fetch_array($result1))
{
$id1 = $row1['id'];
$array1[count($array1) + 1] = $id1;
shuffle($array1);
}
shuffle($array1);
//ACCESS THE RANDOM NUMBER IS BY $array1[0]
//Now we have the id of the random quote.
$random = $array1[0];
$q1 = "SELECT * FROM quotes WHERE id='$random' LIMIT 1";
$r1 = mysql_query($q1);
while ($row1 = mysql_fetch_array($r1))
{
$content = $row1['content'];
$author = stripslashes($row1['author']);
}
//Then just echo $content and $author (the person who said it) when you need it.
?>
It may not be efficient but it works
