views:

18

answers:

1

Hi all:

I am working on The ausdcf.org to try adding several banner ads in swf format to the top.

Everything starts to work, but I've got several questions that need your help:

The client chose not to go with Google AdManager, but prefer a "minimal approach" to do this task.

What I am trying to do is sort of "mimicking" the way Google AdManager does for banners, that is, to split the chance of each particular swf to be shown to the visitor evenly among the banner collection.

Definitely I can add some jQuery code to do this from client-side, a random number generator and if-else statement would work - just $.load() it!

However, what if I'd like to make sure those disabled Javascript (is there any now btw?) still be able to see different swfs in each visit.

Any suggestion on how to approach this?

Many thanks in advance.

+1  A: 

The keyword you're looking for is "rotation script" or "banner rotator", and server-side is definitely the way to do something like this.

For PHP, try:

//available banners
$banners = array(
   'banner1.swf',
   'banner2.swf',
   'banner3.swf'

   //add more here
);

//get random banner
srand((double) microtime() * 1000000);
$rand = rand(0,count($banners)-1);

//display it
echo $banners[$rand];

This won't evenly rotate the inventory, just randomly. To rotate banners evenly, you'd have to keep track of things. Let me know if you need that and I'll post it here.

bobsoap
@bobsoap: Thanks so much for this! Now I will leave it to the client to decide whether he is happy about this approach :)
Michael Mao