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 Banners - Noob with PHP

Discussion in 'PHP' started by dcristo, Sep 19, 2006.

  1. #1
    Is there an easy way with PHP to simply rotate multiple banner advertisments. I am not wanting to use JS as I want the links to be straight html. Any help would be appreciated.

    Thanks
     
    dcristo, Sep 19, 2006 IP
  2. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #2
    Yes.. you can use a mysql database, or encode it in the script it self....


    example of none mysql

    
    <?php
    $adcodes = Array('Code one here','Another code here','And another here','and so on');
    $ctr = count($adcodes) -1;
    $l=rand(0,$ctr);
    
    echo $adcodes[$l];
    
    ?>
    
    Code (markup):
    This sample is random select of ads... to display everytime a page display....
     
    PinoyIto, Sep 19, 2006 IP
    dcristo likes this.
  3. Vizuke

    Vizuke Peon

    Messages:
    339
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How would you add a new code to that array without hardcoding it?
     
    Vizuke, Sep 19, 2006 IP
  4. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #4
    Thanks for the help PinoyIto, that's exactly what I wanted to achieve.

    Vizuke, what do you mean by hardcoding? As in, putting banner code for each additional banner in the code?
     
    dcristo, Sep 19, 2006 IP
  5. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #5
    If you don't want hard coded, you may use mysql and store all your codes there and call them randomly but this will eat more resources of your server than the hard coded one.
     
    PinoyIto, Sep 20, 2006 IP
  6. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #6
    No this solution is great. Still yet to test it though.
     
    dcristo, Sep 20, 2006 IP