|
|
This is the Websiteology : Quotes Code Page
|
|
website quotes program description |
 |
 |
Suppose you were an idiot... And suppose you were a member of Congress... But I repeat myself.
--Mark Twain
|
|
That quote by Mr Clemmons above set me off once again. Of course, just including the quote wasn't enough .. after all .. this is
in most part, a visual medium. Gotta include a photo of the person making the quote!
This was easy and fun. Got to play with arrays, random numbers and then simply mixed them into a little HTML stew.
|
|
I set up three arrays. One for the quote ($quote), one for the quoted ($quoteauthor) and one for the graphic ($quotepic).
The hardest part is probably making sure that in each array the quote, author and picture match.
|
$quote = array (
"When the need arises - and it does - you must be able to shoot your own dog.",
"Suppose you were an idiot... And suppose you were a member of Congress... But I repeat myself.");
$quoteauthor = array (
"--Robert A. Heinlein",
"--Mark Twain");
$quotepic = array (
"<img src=\"graphics/photos/quotes/heinlein.gif\" alt=\"Robert A. Heinlein\" width=\"76\" height=\"100\" border=\"0\" align=\"left\">",
"<img src=\"graphics/photos/quotes/mark_twain.gif\" alt=\"Mark Twain\" width=\"69\" height=\"100\" border=\"0\" align=\"left\">");
|
|
We want to pull the quotes out at random so we count the array elements, seed the random number thingie and get a
random number.
|
// Count the number of elements in the $quote array
$quotecount = count($quote);
// Seed random
srand ((double) microtime() * 1000000);
// Get Random number
$RandomNumber = rand (0,$quotecount - 1);
|
|
Finally, echo it to the screen.
|
echo ("<table width=\"200\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" align=\"left\">");
echo ("<tr>");
echo ("<td bgcolor=\"#ACC8C5\">$quotepic[$RandomNumber] $quote[$RandomNumber]</td><td> </td>");
echo ("</tr>");
echo ("<tr><td bgcolor=\"#ACC8C5\">$quoteauthor[$RandomNumber]</td><td> </td></tr>");
echo ("</table>");
|
|
The file is simply included in the home page like so:
|
<?
include "quotes.php";
?>
|
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 eTraxx.com |
|