PHP ad rotation

Discussion in 'HTML & Website Design' started by RebateFX.com, Feb 23, 2007.

  1. #1
    Hi

    Can anyone point me to a nice tutorial on rotating banner ads on my site?
    Perhaps using PHP includes? Any other "easy" methods of doing it?

    Cheers
     
    RebateFX.com, Feb 23, 2007 IP
  2. iatbm

    iatbm Prominent Member

    Messages:
    5,151
    Likes Received:
    352
    Best Answers:
    0
    Trophy Points:
    360
    #2
    iatbm, Feb 23, 2007 IP
  3. usamzi

    usamzi Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The Simplest form of Ad Rotatation using PHP:
    Ads will be stored in a text file and picked randomly by PHP script.
    The Text file 'banner_ads.txt' will look like:-
    --------------------------------
    <a href="target path">
    <img src="target image"></a>
    *
    <a href="target path">
    <img src="target image"></a>
    --------------------------------
    where * is used for individualizing banners.
    The PHP code will be like:-
    --------------------------------
    <?php
    $content = join ('', file ('banner_ads.txt'));
    $s_con = split("*",$content);
    $banner_no = rand(0,(count($s_con)-1));
    echo $s_con[$banner_no];
    ?>
    --------------------------------
    Of course you can use the same procedure for any content to display randomly other than banner ads like 'random quotes' etc.
     
    usamzi, Feb 24, 2007 IP
  4. RebateFX.com

    RebateFX.com Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot guys. It seems to be even simpler than I thought.
    I'm learning more and more about PHP these days. Using things like includes make designing and updating a site so much easier. :)
     
    RebateFX.com, Feb 24, 2007 IP