August 9, 2009 at 7:44 pm #25701
the home page image at the top of the page changes each time you enter the page, how is this done?
AlAugust 9, 2009 at 8:53 pm #61811
Matt Mullenweg developed the code for a method to achieve this here: http://ma.tt/scripts/randomimage/ (it’s been improved upon since, but you’ll get all the detail from the site anyhow).
It will automatically change because of the links on it.August 10, 2009 at 1:40 pm #61965
I’m a huge fan of PHP for this. So much so that I’m moving this topic to the PHP section!
You can simply use the rand() function to achieve the results. Here’s a really simple explanation:
http://php.about.com/od/finishedphp1/qt … banner.htm
Essentially, it’ll be something like this:
$num = rand(1, 5);
<img class="classname" alt="" src="images/banner-<?php echo $num; ?>.jpg" />August 11, 2009 at 3:54 pm #62092
I like that a lot – look waaaaaay simpler than any other method I’ve seen. Nice one.
You must be logged in to reply to this topic.