bahattab
28-01-2008, 03:18 PM
Simple Ad Rotator
http://www.phpbuddy.com/images/dot.gif
Overview: Creating a simple ad-rotator. In this ads are stored in a text file and picked randomly by this PHP code.
Most of the webmaster use banner ads, we will be creating a very simple banner rotator, which picks up randomly one ad from the banner file and displays it, this file can be called in any other page to display the banners.
We will be storing banner ads in a text file banner_ads.txt
banner_ads.txt
<a href="http://www.qksrv.net/click-1035775-3999547" target="_top" >
<img src="http://www.qksrv.net/image-1035775-3999547" width="468" height="60" alt="null" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-10346" target="_top" >
<img src="http://www.qksrv.net/image-498294-10346" width="468" height="60" alt="Click here for Commission Junction" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-896771" target="_top" >
<img src="http://www.qksrv.net/image-498294-896771" width="468" height="60" alt="null" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-541523" target="_top" >
<img src="http://www.qksrv.net/image-498294-541523" width="468" height="60" alt="Dotster $14.95 Domain Name Registration" border="0"></a>
Note that the banners are seperated by ~ in our banner file.
ad_rotator.phphttp://www.phpbuddy.com/icon/run.gifView Sample Output (http://www.phpbuddy.com/sample/ad_rotator.php)
<center>
<?php$fcontents = join ('', file ('banner_ads.txt'));$s_con = split("~",$fcontents);$banner_no = rand(0,(count($s_con)-1));echo $s_con[$banner_no];?>
</center>
The above 'ad_rotator.php' can be included in any PHP page to display a banner ad by using include 'ad_rotator.php'; tag wherever banner is required.
The above concept can be also be used to display random quotes etc, just modify the banners_ads.txt with the random content you want.
http://www.phpbuddy.com/article.php?id=4
http://www.phpbuddy.com/images/dot.gif
Overview: Creating a simple ad-rotator. In this ads are stored in a text file and picked randomly by this PHP code.
Most of the webmaster use banner ads, we will be creating a very simple banner rotator, which picks up randomly one ad from the banner file and displays it, this file can be called in any other page to display the banners.
We will be storing banner ads in a text file banner_ads.txt
banner_ads.txt
<a href="http://www.qksrv.net/click-1035775-3999547" target="_top" >
<img src="http://www.qksrv.net/image-1035775-3999547" width="468" height="60" alt="null" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-10346" target="_top" >
<img src="http://www.qksrv.net/image-498294-10346" width="468" height="60" alt="Click here for Commission Junction" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-896771" target="_top" >
<img src="http://www.qksrv.net/image-498294-896771" width="468" height="60" alt="null" border="0"></a>~
<a href="http://www.qksrv.net/click-498294-541523" target="_top" >
<img src="http://www.qksrv.net/image-498294-541523" width="468" height="60" alt="Dotster $14.95 Domain Name Registration" border="0"></a>
Note that the banners are seperated by ~ in our banner file.
ad_rotator.phphttp://www.phpbuddy.com/icon/run.gifView Sample Output (http://www.phpbuddy.com/sample/ad_rotator.php)
<center>
<?php$fcontents = join ('', file ('banner_ads.txt'));$s_con = split("~",$fcontents);$banner_no = rand(0,(count($s_con)-1));echo $s_con[$banner_no];?>
</center>
The above 'ad_rotator.php' can be included in any PHP page to display a banner ad by using include 'ad_rotator.php'; tag wherever banner is required.
The above concept can be also be used to display random quotes etc, just modify the banners_ads.txt with the random content you want.
http://www.phpbuddy.com/article.php?id=4