Create a Rotating Ads
If you run more than one ads, but lack of space to put the ads, you can actually rotate the ads.
The code below will create a random number from 1 to 10. Since I want both ads to be shown with a probability of 50%, I put the condition if (x > 5). You can change this number.
1 2 3 4 5 6 7 8 9 10 | <?php $x = rand(1,10); ?> <?php if ($x > 5) { ?> <!--your first ad code--> <?php } else {?> <!--your second ad code--> <?php } ?> |
You can read more about PHP rand() function here.
If you liked this post, these other posts might also be interesting to you:
Category: Blog Tips, PHP | Comment (RSS) | Trackback

Norhafidz:
Nice info there, thanks, I was searching for the code and now I can implement it on my blog! keep giving more helpful information.
June 13, 2008, 6:42 pmKNizam:
perghhhhh too techie la for me. hehe
June 13, 2008, 9:30 pmselinap.com:
KNizam: You just need to copy and paste it to the place where you want it to appear in the template file.
June 14, 2008, 8:57 am