Best method 2 Change bckground header img randomly?

What is the best method to get a background image header/banner/title-bar to automatically and randomly change each time the page is opened. I read a PHP book that changed the image seasonally. What would be the best: flash, java, actionscript. or the php or anything else? I’m willing to explore and learn :eek: thx in advance for any ideas.

PHP looks tops so far, I got a book on that 1 :rolleyes:. The appeal of JavaScript is being on the page. Atsea can you direct me toward working examples or code to have a look at the mechanics?

Expanding the idea. Can you mix-up a “shtml” site with PHP added onto a working shtml site? Out of curiosity… interest??? Thx for the help above and any to follow bellow

Acid, google javascript random image. There are a ton of examples out there. :slight_smile:

Well, just to be picky, I will point out that none of these techniques produce a “random” image, merely a “pseudo random” one, since no computer algorithm can produce a truly random sequence on it’s own.

As far as I remember you cannot mix both; SHTML with PHP in that sense, i.e. on the same page.

the two best choices would be javascript and php. Javascript could be used on html pages where as php has to be used on a .php file.

In other words you have to make sure your server supports php. Otherwise do it with a simple javascript random script.

I would use PHP for this. Flash and the likes are way to heavy tools to solve this relatively simple problem.

Assuming you have image1.jpg, image2.jpg, … imageN.jpg, a simple snippet like this will do:


<img src="image<?php echo rand(1, 10); ?>.jpg" alt="" />

Or you could put all images in an array and pick one at random.

(code assumes you have 10 images)