Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Books
Software
Downloads
Hosting
manuals
Forums
Script directory
Training
Our Links

ADD TO Progged Progged
ADD TO DEL.ICIO.US Del.icio.
ADD TO DIGG Digg
ADD TO FURL Furl
ADD TO NEWSVINE Newsvine
ADD TO NETSCAPE Netscape
ADD TO REDDIT Reddit
ADD TO STUMBLEUPON StumbleUpon
ADD TO TECHNORATI FAVORITES Technorati
ADD TO SQUIDOO Squidoo
ADD TO WINDOWS LIVE Windows Live
ADD TO YAHOO MYWEB Yahoo MyWeb
ADD TO ASK Ask
ADD TO GOOGLE Google
ADD TO MAGNOLIA Magnolia
ADD TO SPURL Spurl



 
 

SPONSORS



 
 

Displaying random banners

The best way to earn money with your site is to be able to rotate banners , so what if you had banners for advertisers and wanted to show a different one each time . Well this example uses 4 banners ( create your own ) , 4 urls and 4 set of alt tags . We store these in array's and then generate a random number , this random number will be what decides what banner is displayed .

Code :

<?php
//our banners , use your own here
$imgsrc = array("ihcomputing1.gif" ,
"ihcomputing2.gif" ,
"ihcomputing3.gif" ,
"ihmusic1.gif");
//the urls for the links , replace these also
$url = array("http://mycomputing.bcentral-vstore.com",
"http://mycomputing.bcentral-vstore.com",
"http://mycomputing.bcentral-vstore.com",
"http://musicformasses.bcentral-vstore.com");
//this is alt tags which help with search engines and
//also people who switch off their images in their browsers
$alt = array("all your favorite computing products",
"many computer bargains available",
"computer shopping at its best",
"music for everyone ");
//generate a random number
srand((double)microtime() * 1000000);
$rn = (rand()%4);
//display the banner and link . This opens in a new window
echo ("<a href=$url[$rn] target=\"new\"><img src =$imgsrc[$rn] alt =$alt[$rn]></a>");
?>

Example :

Press refresh / reload to see a different banner

 

music