Using the AdRotator Class

vedanta dot barooah at gmail dot com

 

Consider the following code:

 

1.     <?php

2.     // include the main class file

3.     include("adrotator.class.php");

4.     // make a image pool as an array

5.     $image_array=array("one.gif","two.gif","three.gif","four.gif","five.gif","six.gif","seven.gif");

6.     // instance of the class

7.     $o = new AdRotator($image_array);

8.     // set the number of images to be shown

9.     $o->rotate(5);

10.  // get the images in an array

11.  $img=$o->getImages();

12.  // display the images

13.  for($i=0;$i<count($img);$i++){

14.  ?>

15.  <img src="./images/<?=$img[$i]?>" style="border:thin solid #ffffff "><br>

16.  <?

17.  }

18.  ?>

 

Line 2: Includes the main class file

Line 5: Define an array that contains all the image (ads) name

Line 7: The constructor of the class takes this image array as argument

Line 9: Sets the number of images that are to be displayed in the page

Line 11: Returns an array of the randomized images

Line 15: Once you have the images, display them (There are other ways to do the image display, the above is just one method)

 

ENJOY!

 

J