Random Banner

Discussion in 'PHP' started by zdestiny, Apr 26, 2006.

  1. #1
    I have created lots of diff banners for my site. I want these banners to rotate ie I want a different banner to load every time someone refreshes the page.

    But I want to do all this on my phpbb board, so I think the script will have to be in php. can someone help me out?
     
    zdestiny, Apr 26, 2006 IP
  2. icare

    icare Peon

    Messages:
    714
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    thats exactly I am doing rite now

    i mean installing phpadsnew

    Thats what you need
    http://phpadsnew.com/two/index.html
     
    icare, Apr 26, 2006 IP
  3. zdestiny

    zdestiny Peon

    Messages:
    138
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    but i dont have a paid or ad banner. im just talking about diff graphic banners that i made for my site.
     
    zdestiny, Apr 26, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $Ad[0] = '<a href="http://www.site.com" TARGET="_blank">Site 0</a>';
    $Ad[1] = '<a href="http://www.site1.com" TARGET="_blank">Site 1</a>';
    $Ad[2] = '<a href="http://www.site2.com" TARGET="_blank">Site 2</a>';   
         
    $Weight[0]=3;
    $Weight[1]=3;
    $Weight[2]=3;            
    $sum =0;   
     
    for($i=0;$i<count($Weight);$i++)        
    $sum+=$Weight[$i];    
    $ShowAd = rand(0, $sum - 1);    
    for($i=0;$i<count($Weight);$i++)    {        
    if($ShowAd<=$Weight[$i])        {            
    $ShowAd=$i;            
    break;        
    }        
    else            
    $ShowAd-=$Weight[$i];   
     }    
    echo $Ad[$ShowAd]; 
    
    PHP:
     
    mad4, Apr 27, 2006 IP
  5. ontheweb

    ontheweb Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As mad4 has shown, you can whip up some PHP code to do this very quickly. However, long term I suggest looking at phpadsnew even just for the statistics it will give you.
     
    ontheweb, Apr 27, 2006 IP
  6. zdestiny

    zdestiny Peon

    Messages:
    138
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    that code displays text only, do i just add an 'img' code for images ?
     
    zdestiny, Apr 27, 2006 IP
  7. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah, alter the html code as you wish.
     
    mad4, Apr 27, 2006 IP
  8. websys

    websys Active Member

    Messages:
    841
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    78
    #8
    i recently added a banner rotator in my Blog , which rocks . i am using the script from Automatic Labs
     
    websys, Apr 29, 2006 IP
  9. zdestiny

    zdestiny Peon

    Messages:
    138
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    zdestiny, Apr 29, 2006 IP
  10. websys

    websys Active Member

    Messages:
    841
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    78
    #10
    yes thats the one
     
    websys, Apr 29, 2006 IP
  11. supriyadisw

    supriyadisw Peon

    Messages:
    203
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yes, that's a great images rotator script.

    Have a nice day
     
    supriyadisw, Sep 13, 2006 IP