This is a little snippet of code I’ve been using since forever now. It is a simple way of putting quotes, or any other data you want, on your site and having it rotate randomly through the different items you specify. I’ve used this in a bunch of different ways and it has thus far not failed. Not sure where I found it though, as it’s been so long.
The download (here) has three files, but you only really need two.
- The first you need to edit is randomquote.php, it has comments in it to identify what you need to change, but the short of it is you need to edit the web server path to where your files are stored. The only other thing you need to edit here is to set $random to false if you want quotes to be displayed sequentially.
- Next add your quotes to the randomquote.inc, or if you want to have them sequentially displayquote.inc. Make sure the quote is on one line, no wrapping, and don’t leave a blank line.
- UPLOAD!
- Now to place the random quote in your php file
<?include("randomquote/randomquote.php"); ?>
On my own site I use it to display client quotes in the footer as well as the right bar on the homepage. I put the random quote include inside a div styled for the area it’s in, and it displays it in both sections without having to have two separate quote scripts running.
On a recent clients site I used it to bring up quotes, but each quote had to have different styling. So I included the div and other tags in the quote file itself for each quote.
And on another site I used it to randomly rotate an entire header along with random graphics. So you should be able to find this useful in any application with a bit of cleverness.























JamieO | February 24th, 2008 at 12:26 am #
Great explanation of how to! For those who use Wordpress, there is a plugin to bring the same type of functionality into the admin console, Zombie Robot Quotes. I have used it on a couple of client sites in the same way as your process and the good thing is non-technical authors can maintain their quote list for themselves. It actually drives the alien speech bubble in my blogs’ current design.
Dom-Casino | May 10th, 2008 at 12:42 pm #
John, Great post this is.
I am confused to use now wordpress theme, because there are lacks of blogs with the same design.
should i have an unique design blog, how much it is good to have blog with unique design? waiting for your response. John Peterson.