View Single Post
Old 10-28-2005, 02:47 PM   · #2
mholt
DNOA Member
 
mholt's Avatar
 
Name: Matthew Holt
Location: Utah
Trader Rating: (75)
Join Date: May 2004
Posts: 4,891
NP$: 17.21 (Donate)
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
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


Please register or log-in into NamePros to hide ads
__________________
...
mholt is offline   Reply With Quote
Site Sponsors
The new .TEL domain HostGator HostGator
Advertise your business at NamePros
All times are GMT -7. The time now is 08:45 PM.


Powered by: vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.