php: Random Advertisement Link

Will display a random advertisement, each time the page loads. Look to your right, and hit refresh.

The PHP code

just put this below code at the top of the page. Remember this is PHP so the browser will not render this code.

then place this tag on the page where you want to show the ad: <? showRandomAd(); ?>

<?

<!-- code written by Benjamin Austin
You can use this code where ever you want, just please leave this comment in.
links are always apreciated -->

function showRandomAd(){
  $advertisementImageFolder = "http://www.benniaustin.com/ads/"; // the folder where the images live;

  $advertisementLink[0] = "http://www.shareasale.com/r.cfm?b=72836&u=222245&m=5993&urllink=&afftrack=";
  $advertisementImage[0] = "snorg_skyscraper_01.jpg";

  $advertisementLink[1] = "http://www.shareasale.com/r.cfm?b=72836&u=222245&m=5993&urllink=&afftrack=";
  $advertisementImage[1] = "snorg_skyscraper_02.jpg";

  $advertisementLink[2] = "http://www.shareasale.com/r.cfm?b=72836&u=222245&m=5993&urllink=&afftrack=";
  $advertisementImage[2] = "snorg_skyscraper_03.jpg";

  $advertisementLink[3] = "http://www.shareasale.com/r.cfm?b=72836&u=222245&m=5993&urllink=&afftrack=";
  $advertisementImage[3] = "snorg_skyscraper_04.jpg";
  
  //you can add more too if you need. As many as you like
  
  $random = (rand()%count($advertisementImage));
  $adImage= $advertisementImageFolder . $advertisementImage[$random];

  echo '<a class="adlink" href="' . $advertisementLink[$random] . '"><img src="' . $adImage . '"/></a>';
}
?>