Free banner rotator for website

SIMPLE BANNER ROTATOR WITH PHP

After release of our first tutorial here :- Banner Rotator Code for Faucets  some of my friend said they are not good in sql thing. So make more simple. Here i am coding same thing again without use of MYSQL. Hope it works for everyone.

LEARN HOW TO MAKE FREE PHP BANNER ROTATOR
STEP 1 :-

First make a php page and add this function and include that page in same page where you want to display ads , or add this function in your existing function.php file.

#FUNCTION FOR BANNER ROTATOR#
function bannerRot($file){
  $adfile = file_get_contents($file);
  $adx = explode('~',$adfile);
  $countarray = count($adx);
  $randomad = rand(0,$countarray-1);
  return $adx[$randomad];
}
#FUNCTION FOR BANNER ROTATOR#
STEP 2 :-

Now make a .txt file with anyname u like, i will suggest to make .txt files with adsizes so that you can understand at the time of edit where to ad code.

So best is to make .txt files like this

728×90.txt

468×60.txt

Add code in those files like this. An example given below

<div style="border:1px solid #000;width:468px;height:60px;text-align:center;line-height:60px;background-color:#000;color:#fff;">
BANNER ADS ONE
</div>

~

<div style="border:1px solid #000;width:468px;height:60px;text-align:center;line-height:60px;background-color:#735e05;color:#fff;">
BANNER ADS TWO
</div>

~

<div style="border:1px solid #000;width:468px;height:60px;text-align:center;line-height:60px;background-color:#320add;color:#fff;">
BANNER ADS THREE
</div>

-> ~ this simbol is important to separate many codes.

STEP 3 :-

Use this code where ever you want to display ads.

<?php 
echo bannerRot('728x90.txt');
?>

The above code is an example to display random ad from 728×90.txt file. The more codes will rotate codes randomly.

I hope you like our tutorials and use them in your website. Enjoy you time and share our blog in your friends.

Leave a Reply

Your email address will not be published. Required fields are marked *

27  ⁄    =  3