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