Forgot Password / Register
Site Statistics
Total Members: 510
Total Tutorials: 242
Newsest User: Hp
Todays Unique Hits: 119
0 Users 2 Guests Online

Random banner

Okay heres how to make a page which shows random banners everytime you visit the page (or reload it).

PHP Code
1
2
3
4
5
6
7
8
9
10
11
<?
//Create an array so we can sort the banners out in order of 1, 2 and 3
$banners= array("banner1.gif""banner2.gif""banner3.gif");

//Create a random number to use later on (must be from 0 to 2 if ur using 3 banners
$randomnumberrand(02);

//Now time to make the random image
echo "<img src='$banners[$randomnumber]'>";
?>


Thanks, please post comments and report any bugs or mistakes you find
ilyas-shezad
Views:
1603
Rating:
Posted on Wednesday 9th April 2008 at 07:22 PM
DanielXP
DanielXP
PHP Code
1
2
3
4
5
6
7
8
9
10
11
<?
//Create an array so we can sort the banners out in order of 1, 2 and 3
$banners = array("banner1.gif""banner2.gif""banner3.gif");
$links = array("link 1""link 2""link 3");

//Create a random number to use later on (must be from 0 to 2 if ur using 3 banners
$randomnumber rand(02);

//Now time to make the random image
echo "<a href='" $links[$randomnumber] . "'><img src='" $banners[$randomnumber] . "'></a>";
?>
Posted on Wednesday 9th April 2008 at 06:31 PM
Dalez
Dalez
Is there anyway to make it so they could all have a link? And when i mean link, i mean they all have different links..
Posted on Saturday 9th February 2008 at 02:50 PM
Liquidsteel
Liquidsteel
Not Bad
Posted on Tuesday 16th October 2007 at 01:48 AM
Thug
Thug
Works great, AND it looks REALLY good on my site...thank you for this tut.
Posted on Sunday 12th August 2007 at 05:14 PM
-=InSaNe=-
-=InSaNe=-
I will try it soon, but thanks because I needed something like that.