Do you have a favorite quote? (how I pieced together my Random quote widget).

I’ve been working on a widget that displays a random quote in the sidebar (or wherever you put it). It’s been a fun little project and I’ve really enjoyed working on it. I used the Executable PHP script from Otto and a bit of code I found laying around on the internet one day. I wish I had the link for that. But it’s simple enough.

Just drop in your widget from above and edit it.

Here’s the code you need to make it happen.

<?php

$quotes[] = “<i>You can insert your quote here.</i><br><b>~Author’s name</b>”;
*/for each new quote just copy and paste the above modifying the quote and author’s name.

srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);

echo “<p>” . $quotes[$randomquote] . “</p>”;

?>

———————

 

I am also looking for a few new great quotes to add. So if you find a good that you like, let me know in the comments here and I’ll add it to my collection.

One Response to Do you have a favorite quote? (how I pieced together my Random quote widget).
  1. William
    May 29, 2007 | 2:10 am

    Nevermind… this used to work prior to updating wordpress. Not anymore.

Leave a Reply


Wanting to leave an <em>phasis on your comment?

Trackback URL http://www.williamlehman.net/do-you-have-a-favorite-quote-how-i-pieced-together-my-favorite-quote-widget/trackback