Drupal - Display Random Quotes

The following PHP snipet allows you to add a block to your Drupal site that will display a random quote from a list of user defined quotes.

Create a new block. Set the input format to PHP code. Then paste in the following (changing the quotes as desired, obviously):

<?php
$quotes[] = "Quote 1";
$quotes[] = "Quote 2";
$quotes[] = "Quote 3";
$quotes[] = "Quote 4";
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo "<div class=\"quote\"><p>\"";
echo $quotes[$randomquote];
echo "\"</p></div>";
?>

That's it. Now add the block to your site as normal.


Warning: INSERT command denied to user 'revjbr_dan'@'10.0.0.14' for table 'watchdog' query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '<em>INSERT command denied to user &amp;#039;revjbr_dan&amp;#039;@&amp;#039;10.0.0.14&amp;#039; for table &amp;#039;sessions&amp;#039;\nquery: INSERT INTO sessions (sid, uid, cache, hostname, session, timestamp) VALUES (&amp;#039;ddb0d1b775a514423cffba4a5961468e&amp;#039;, 0, 0, &amp;#039;38.107.179.238&amp;#039;, &amp;#039;&amp;#039;, 1328688646)</em> in <em>/home/www/danpearce.co.uk/includes/database.mysql.inc</em> on line <em>172</em>.', 2, '', 'http://www.danpearce.co.uk/drupal_random_quote', '', '38.107.179.238', 1328688646) in /home/www/danpearce.co.uk/includes/database.mysql.inc on line 172