Welcome, Guest. Please Login or Register.
April 28, 2025, 07:09:39 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Completed mods  |  [All versions - Code] Random Quotes « previous next »
Pages: [1] Reply Ignore Print
Author Topic: [All versions - Code] Random Quotes  (Read 1762 times)
chris
Guest
[All versions - Code] Random Quotes
« on: May 02, 2003, 11:08:37 AM »
Reply with quote

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.... ;D
Logged
Tilton53
Jr. Member
**
Posts: 73


I'm a llama!

Re:[All versions - Code] Random Quotes
« Reply #1 on: May 02, 2003, 05:42:49 PM »
Reply with quote

This was a good idea
Logged
1979Z28
Sr. Member
****
Posts: 324


WWW
Re:[All versions - Code] Random Quotes
« Reply #2 on: July 21, 2003, 01:09:32 PM »
Reply with quote

I'm probably going to be asking too much, but would it be possible to add this to sort of a dbmod file? ;) I don't have direct access to the MySQL of my webserver.. :-X
Logged
Ben_S
Disciple of Joe
Support Team
YaBB God
*****
Posts: 1586


I Love YaBB SE!

WWW
Re:[All versions - Code] Random Quotes
« Reply #3 on: July 21, 2003, 04:26:02 PM »
Reply with quote

you could always download and install phpmyadmin yourself - http://www.phpmyadmin.net
Logged
1979Z28
Sr. Member
****
Posts: 324


WWW
Re:[All versions - Code] Random Quotes
« Reply #4 on: July 22, 2003, 01:09:18 AM »
Reply with quote

It's already installed though :P I'm the assistant webmaster of my webpage, the main webmaster just hasn't given me the 'permission' to access it :P

I might be able to have him import that whole list of stuff if the need arises, but I'd like to try to do every other option besides that :-X
Logged
PZ
Noobie
*
Posts: 16


I'm a llama!

Re:[All versions - Code] Random Quotes
« Reply #5 on: July 22, 2003, 02:46:44 AM »
Reply with quote

Where? Where do the quotes show up? I installed everything with out errors, except I don't see the quotes :o
Logged
PZ
Noobie
*
Posts: 16


I'm a llama!

Re:[All versions - Code] Random Quotes
« Reply #6 on: July 22, 2003, 02:55:48 AM »
Reply with quote

Oops ::) I moved the code around in my Subs and VIOLA! The quotes showed up.

So ... never mind and thanks! I was doing something similar to this with my news and random Steven Wright quotes. Now I have to think of some actual news for my news ;)
Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Completed mods  |  [All versions - Code] Random Quotes « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.029 seconds with 17 queries.