1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rotating Banner Script

Discussion in 'PHP' started by PET, Nov 18, 2012.

  1. #1
    Hello,

    can you recommend me a free and good banner rotating script? I searched on google, only found payed scripts.
    I used to use OpenX but since the upgrade to PHP 5.3 my old version became obsolete and right now I'm looking for an alternative.

    Thank You
     
    PET, Nov 18, 2012 IP
  2. matt_62

    matt_62 Prominent Member

    Messages:
    1,827
    Likes Received:
    515
    Best Answers:
    14
    Trophy Points:
    350
    #2
    i have never used a commercial one so i dont know what features you want / need.
    i have one i created myself that uses a random number to randomly pull up affiliate ads. Its extremely primitive (text editor used to update and manage the ads). would that be useful to you? or what features do you need?
     
    matt_62, Nov 18, 2012 IP
  3. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    All I need is to be able to set up banner positions. I add banners to those positions and then he rotates trough them.
    I need it to be able to display images, html code or javascript.
    I need to be able to disable/enable a banner (not only delete).
     
    PET, Nov 18, 2012 IP
  4. zeesales

    zeesales Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    85
    Articles:
    1
    #4
    Here is rotating banner javascript. I added 10 number of banners. Also change the timeout to require seconds. You can add more banners if you wish or reduce the number of banners if not required.

    
    <!-- Rotating Banner by Uday Kurtkoti -->
    
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var imgs = new Array ("Banner 1  Image URL ","Banner 2  Image URL ","Banner 3  Image URL ","Banner 4  Image URL ","Banner 5  Image URL ","Banner 6  Image URL ","Banner 7  Image URL ","Banner 8  Image URL ","Banner 9  Image URL ","Banner 10  Image URL ")
    var lnks = new Array ("banner 1  URL","banner 2  URL","banner 3 URL","banner 4  URL","banner 5  URL","banner 6  URL","banner 7  URL","banner  8 URL","banner  9 URL","banner 10  URL")
    var altimg = new Array ("")
    var currentAd = 0
    var imgCt = 10
    function cycle() {
    currentAd++
    if (currentAd == imgCt) {
    currentAd=0
    }
    document.adBanner.src=imgs[currentAd]
    document.adBanner.alt=altimg[currentAd]
    adLink.href=lnks[currentAd]
    setTimeout("cycle()",10 * 1000)
    }
    //-->
    </SCRIPT>
    
    <a href="banner 1  URL" name="adLink" target="_blank"><img src="Banner 1  Image URL " name="adBanner" border="0" width="468" height="60"></a>
    
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    cycle()
    //-->
    </SCRIPT>
    
    Code (markup):
     
    zeesales, Nov 19, 2012 IP
  5. ajvixe.org

    ajvixe.org Greenhorn

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    if some one can help me with html code to make rotate html ads code and to be lead to a link ?
    i mean i need to rote many html ads code
     
    ajvixe.org, Jan 25, 2013 IP
  6. Graham Reid

    Graham Reid Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    I've used the above script for several years and its great. I've just discovered it doesn't work in Chrome though.
    "Uncaught reference error - adlink is not defined"
    Can anyone help?
     
    Graham Reid, May 5, 2013 IP
  7. imthebanana

    imthebanana Well-Known Member

    Messages:
    486
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    140
    #7
    <!-- Rotating Banner by Uday Kurtkoti -->
     
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var imgs = new Array ("Banner 1  Image URL ","Banner 2  Image URL ","Banner 3  Image URL ","Banner 4  Image URL ","Banner 5  Image URL ","Banner 6  Image URL ","Banner 7  Image URL ","Banner 8  Image URL ","Banner 9  Image URL ","Banner 10  Image URL ")
    var lnks = new Array ("banner 1  URL","banner 2  URL","banner 3 URL","banner 4  URL","banner 5  URL","banner 6  URL","banner 7  URL","banner  8 URL","banner  9 URL","banner 10  URL")
    var altimg = new Array ("")
    var currentAd = 0
    var imgCt = 10
    var adLink = document.getElementsByName('adLink')[0]
    function cycle() {
    currentAd++
    if (currentAd == imgCt) {
    currentAd=0
    }
    document.adBanner.src=imgs[currentAd]
    document.adBanner.alt=altimg[currentAd]
    adLink.setAttribute('href', lnks[currentAd])
    setTimeout("cycle()",10 * 1000)
    }
    //-->
    </SCRIPT>
     
    <a href="banner 1  URL" name="adLink" target="_blank"><img src="Banner 1  Image URL " name="adBanner" border="0" width="468" height="60"></a>
     
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    cycle()
    //-->
    </SCRIPT>
    Code (markup):
    Should work in chrome
     
    imthebanana, May 5, 2013 IP
  8. iitstudent

    iitstudent Banned

    Messages:
    43
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    23
    #8
    I would recommend you to make your own banner rotating script then using others one you can store pics in images folder and use random function to select random, number and browse that image using img src tag of the html
     
    iitstudent, May 5, 2013 IP
    Pro Designz likes this.
  9. dicecities

    dicecities Well-Known Member

    Messages:
    945
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    110
    #9
    dicecities, Jun 14, 2013 IP
  10. Eurofile007

    Eurofile007 Active Member

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #10
    What about a banner script that can rotate html codes, like Adsense, so you can mix Adsense with the other ads? I have trouble finding one that works.
     
    Eurofile007, Aug 14, 2013 IP
  11. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #11
    Here's a pretty easy one. Just save it under whatever file name you want:

    <?php
    $advert = array();
    
    $advert[] = '<a href="#" target="_blank"><img src="#"></a>';
    $advert[] = '<a href="#" target="_blank"><img src="#"></a>';
    $advert[] = '<a href="#" target="_blank"><img src="#"></a>';
    $advert[] = '<a href="#" target="_blank"><img src="#"></a>';
    $advert[] = '<a href="#" target="_blank"><img src="#"></a>';
    
    shuffle($advert);
    echo $advert[0];
    ?>
    Code (markup):
    Then use an include with your file name:

    <?php include("your-file.php"); ?>
    Code (markup):
     
    qwikad.com, Aug 16, 2013 IP
  12. xxxize

    xxxize Member

    Messages:
    33
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    38
    #12
    Hi, I have create a better one.

    With my rotator you can rotate in the same time scripts like Exoclick ads(scripts) and just image ads with link or even text links.
    Also you can select how many ad spots have in your site. If you have 2 spots script selects 2 unique ads to display.

    This is my code:

    rotator_script.php

    <?php
        // rotator_script.php
        //This is the banner array
        //I have 2 folders one (images/rotator) for image ads and one (rotator) with files which include scripts ads.
        $banners = array(
                array( "title" => "bla bla bla",
                      "img" => "images/rotator/banner1.png",
                      "script" => "",   // this empty because it's image ad
                  "url" => "http://site1.com"
                ),
                array( "title" => "bla bla bla",
                      "img" => "images/rotator/banner2.png",
                      "script" => "",
                  "url" => "http://site2.com"
                ),
                array( "title" => "Exoclick Ad",
                      "img" => "", // this empty because it's script ad
                      "script" => "rotator/exoclick.php",
                  "url" => ""
                ),
                array( "title" => "AdQueen Ad",
                      "img" => "",
                      "script" => "rotator/adqueen.php",
                  "url" => ""
                )
        );
         
        $selectedBanners = array();
         
        function initRotator ($ads) {
                $this->selectedBanners = array_rand($this->banners, $ads); //with array_rand you give the amount of banners which you want to display to have uniques always if you have 2 ad spots you give number 2
        }
     
        function showBanner ($x) {
            $x = $x - 1; // as parameter you can use from 1 until your limit (not 0)
            if (empty($this->banners[$this->selectedBanners[$x]]['script'])) {
                echo '<a href="' . $this->banners[$this->selectedBanners[$x]]['url'] . '" target="blank"><img src="' . $this->banners[$this->selectedBanners[$x]]['img'] . '" alt="' . $this->banners[$this->selectedBanners[$x]]['title'] . '" /></a>';
            }
            else {
                include($this->banners[$this->selectedBanners[$x]]['script']);
            }
        }
    
    ?>
    PHP:
    and you must initialize. Put after this code..

    <?php
    
    initRotator(2); // I have 2 spots in my page
    
    ?>
    PHP:
    and in your spots you put the random rotating ads which change in every refresh.

    <div id="adspot1><?php showBanner(1); ?></div>
    ....
    ....
    ....
    <div id="adspot2><?php showBanner(2); ?></div>
    ....
    ....
    Code (markup):
    I hope that will help you.
     
    xxxize, Sep 8, 2013 IP
  13. Mackos

    Mackos Well-Known Member

    Messages:
    364
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #13
    If you have used OpenX, maybe you can try just DoubleClick from Google?
    Good app for free.
     
    Mackos, Sep 9, 2013 IP