PDA

View Full Version : Random quotes via PHP


ed_lynn
10-20-2002, 08:07 PM
Is it possible to randomly generate qoutes to be inserted in the '<title>' section of my website? I would like to use PHP but if there is a better language to code it in let me know. Does anyone have any script examples?


thanks
ed

Sara
10-21-2002, 05:00 AM
Ed, my friend Bonni has this on her site: http://alicorna.com/scripts.html

Maybe that's what you are looking for...I think it is!! :)

Sara

ed_lynn
10-21-2002, 10:32 AM
sara,

any ideas on why it would not display the quote. it seems to be executing fine. does you friend have an im accoutn i could contact her at?

thanks
ed

harmonic
10-21-2002, 11:59 AM
okay, i'll write a little random quote thing...
to add another quote just add another line like

$quote[] = "Here is a quote";

okay, enough said:


<?

$quote[] = "Quote 1";
$quote[] = "Quote 2";

// DONT EDIT BELOW

srand((double)microtime()*1000000);
$count = count($quote) - 1;
$number = rand(0, $count);
echo $quote["$number"];
?>


now, just put that in any php page where you want the quote to pop up.

ed_lynn
10-21-2002, 01:16 PM
harmonic

WHOA! :wow thanks man that worked out great....

bows to the master

harmonic
10-21-2002, 01:56 PM
Note: If you're php page has a call to srand() in it, you will want to take the one in my script out, as srand should only be called once. It should spit out errors so if everything goes fine just don't worry about it :)