Forum Home
Press F1
 
Thread ID: 51133 2004-11-12 17:57:00 Site Random pic Ron Bakker (356) Press F1
Post ID Timestamp Content User
291034 2004-11-12 17:57:00 I want to have about eight different pictures for my header on my site, so that every time someone clicks onto my home page they get a different picture in the top left of my site. & that the picture is randomly selected.
Cheers Ron
www.ronsseacorner.co.nz
Ron Bakker (356)
291035 2004-11-12 18:43:00 It'll work with PHP
<?php
$mypic=array("pic1.jpg", "pic2.jpg", "pic3.gif", "pic4.jpg", "pic5.jpg"); // this var only needs to be initalised once.
$randomval=rand(0,4); // PHP 4.2+ doesnt requre the random number generator to be seeded..
echo ("$mypic[$randomval]");
?>HTH

Mike.
Mike (15)
291036 2004-11-12 23:26:00 What is PHP?
Sorry about the silly question.
Would the code go into the head or the body?
Cheers Ron Bakker
Ron Bakker (356)
291037 2004-11-13 01:59:00 Hi Ron,

Check out the PHP script here:

automaticlabs.com

They have real good instructions for installing it.

I'm using it on this site: http://www.estherkamkar.com/

The PHP script needs to go in the same folder as your rotating images. In my case this is called: imagerotation

HTH :)
braindead (1685)
1