Forum Moderators: coopster

Message Too Old, No Replies

Need help with simple Rotating ad script

         

BlackRaven

11:54 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



hi,
having a bit of a problem with my simple php ad script. The thing is i want to rotate the ads randomly.

This is my layout

+++++++++++++++++++++++++++++++++++++++++
Country ¦ Ad1 ¦Ad2 ¦ Ad3
+++++++++++++++++++++++++++++++++++++++++

however i ran into a bit of a problem, when suppose one of the ad space is blank say for example it is ad2 that is blank, how do i implement a loop to see ad1 or ad3 (randolmy), and if one of them is not blank then randomly display the corresponding ad.

gotten this far

If(somecountry==$country){

}

Thank You

dreamcatcher

8:35 am on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi BlackRaven,

I would store the data in an array, give them a shuffle using the shuffle() [uk.php.net] function and then output something from a certain slot. Each time you refresh you should get a different output.

Example for random image:


$images = array('image1.jpg','image2.jpg','image3.jpg');
shuffle($images);

echo $images[0];

dc

BlackRaven

8:49 am on May 1, 2005 (gmt 0)

10+ Year Member



would it be possible to modify the array(guessing would need a loop), so that if the entery for ad2 space is blank it would shuffle through the remaining 2 ads?