The random quote TW thing..

Rovero

Veteran XV
I was thinking of something similiar for a website I visit. What is involved in making that? The ones I looked at on the web were pretty cumbersome (involving two .php pages and DB backend).
 
Yaason said:
just cause i drink alone doesnt mean im an alchy
no, but the whole "seeing elvis and trying to drink him under the table" while alone thing does.
 
Yogi said:
There's lots of ways to do it. We use the DB but you can use flat files too.

Did you make the code Yogi? I was browsing hotscripts.com and found a bunch. I was just afraid of adding more connections to the DB for each page access. I guess the size is negligible in the end.
 
its pretty damned easy to code it in php...

create a list of quotes (probably would be better if you threw it in a seperate file) and create an array
use the built in function that counts the number of elements
generate a random number from 0 to that number-1
echo out array[random number]
 
<?

//**************************************//
// SINGLE-LINE QUOTE DISPLAYER v1.0 //
// COPYRIGHT (C) 2005 BRANDON HEYER //
// brandonheyer@gmail.com //
//**************************************//

function randomQuote ($file) {
$f = file($file);
$k = array_rand($f);
$q = $f[$k];
echo $q;
}

?>
 
Back
Top