Open Subs.php and add the following function to it:
function yyRandomQuote()
{
global $db_prefix;
$sqlquery = 'SELECT * FROM '.$db_prefix.'quotes ORDER BY RAND() LIMIT 1';
$request = mysql_query($sqlquery) or database_error(__FILE__, __LINE__);
if ($request)
{
$qdata = mysql_fetch_assoc($request);
mysql_free_result($request);
echo nl2br(htmlspecialchars($qdata['quote']));
}
}
now add <yabb RandomQuote> somewhere to your template....
last but not least, create a new table:
CREATE TABLE `yabbse_quotes` (
`quote` text
) TYPE=MyISAM;
and fill it with some quotes...
INSERT INTO yabbse_quotes VALUES("It was all very well going about pure logic and how the universe was ruled by logic and the harmony of numbers, but the plain fact was that the disc was manifestly traversing space on the back of a giant turtle and the gods had a habit of going round to atheists\' houses and smashing their windows.\r\n\r\n(Colour of Magic)");
INSERT INTO yabbse_quotes VALUES("\'But it\'ll kill him!\'\r\n\'It could have been worse.\'\r\n\'What?\'\r\n\'It could have been us.\'\r\n\r\n(Colour of Magic)");
INSERT INTO yabbse_quotes VALUES("\'Where do shadows come from? That\'s where the wind is blowing!\'\r\n\r\n(Colour of Magic)");
INSERT INTO yabbse_quotes VALUES("\'You\'re your own worst enemy, Rincewind,\' said the sword.\r\nRincewind looked up at the grinning men.\r\n\'Bet?\'\r\n\r\n(Colour of Magic)");
INSERT INTO yabbse_quotes VALUES("The only reason for walking into the jaws of Death is so\'s you can steal His gold teeth.\r\n\r\n(Colour of Magic)");
INSERT INTO yabbse_quotes VALUES("This is to say: while it was true that they had just appeared in this particular set of dimensions, it was also true that they had been living in them all along. It is at this point that normal language gives up, and goes and has a drink.\r\n\r\n(Colour of Magic)");
( a SQL-File with more than 900 quotes from Terry Pratchett's Discworld-Books can be found here:
http://www.tagdocs.de/yse/discworld.zip )
Now a random quote is shown every time you open a page....
