Any way to make a script that randomizes between my adsense banner and img banners?

Discussion in 'HTML & Website Design' started by seant, Sep 16, 2005.

  1. #1
    Hello,

    I want to randomly display my adwords banner and a banner hosted on my site.

    Is there any way to do this?

    Here is what the adsense looks like:
    <script type="text/javascript"><!--
    google_ad_client = "pub-9713982568167945";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_type = "text";
    google_ad_channel ="";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    Code (markup):
    and the banner is: http://www.thepartylive.com/banners/BANNER468X60-2.gif


    Basically I just want a script, similar to a random image script to alternative between these two and possibly more in the future. Any idea how I can do this?

    My site for reference: http://www.volconvo.com

    Thank you!
     
    seant, Sep 16, 2005 IP
  2. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #2
    have you tried phpmyads (i think thats wot its called) or have a look on hotscripts.com
     
    just-4-teens, Sep 16, 2005 IP
  3. lorien1973

    lorien1973 Notable Member

    Messages:
    12,206
    Likes Received:
    601
    Best Answers:
    0
    Trophy Points:
    260
    #3
    Gotta be a simple php random function right?

    x=random(1) if x=0 show ad1 else show ad2?

    I'd go with something a little more decisive myself, so you can get an accurate split, if that is the goal.
     
    lorien1973, Sep 16, 2005 IP
  4. iTISTIC

    iTISTIC Peon

    Messages:
    140
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What platform does your site run on? I could code you a quick ASP snippet to do this. Not sure if it's against AdSense TOS or not, but thats for you to worry about ;)

    PM me if you're interested.
     
    iTISTIC, Sep 16, 2005 IP
  5. honey

    honey Prominent Member

    Messages:
    15,555
    Likes Received:
    712
    Best Answers:
    0
    Trophy Points:
    325
    #5
    honey, Sep 16, 2005 IP
  6. dkin69

    dkin69 Active Member

    Messages:
    644
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #6
    I used to do it like this

    Put all your code into a database and display it like so.

    Worked quite well for me.

    function ads()
    {			
    global $connect;
    $result = mysql_query("SELECT * FROM ads ORDER BY RAND(NOW()) LIMIT 1", $connect) or die ("query 1: " . mysql_error());
    $num_rows = mysql_num_rows($result);
    
    if ($num_rows > 0)
    {
    $row = mysql_fetch_array($result) or die ("query 2: " . mysql_error());
    
    }
    				
    return $row['code'];
    }
    Code (markup):

    This way in the future you simply add a row to the database upload the banner and you have a new banner showing on your site.
     
    dkin69, Sep 17, 2005 IP
  7. seant

    seant Peon

    Messages:
    551
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #7
    double post
     
    seant, Sep 17, 2005 IP
  8. seant

    seant Peon

    Messages:
    551
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Wait I'm confused...

    do I just paste this code:
    < ?php
    $number=mt_rand(1, 2);
    
    if ($number=="1") {
    
    include "adsense.txt"; #include the text file with adsense code 
    
    }
    else
    
    {
    include "YPN.txt"; #include the text file with ypn code
    
    }
    ?>
    
    Code (markup):
    into my header and where include is link to my actual text files (include "http://www.volconvo.com/YPN.txt")

    I am confused :(
     
    seant, Sep 17, 2005 IP
  9. seant

    seant Peon

    Messages:
    551
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #9
    no ideas guys?
     
    seant, Sep 19, 2005 IP
  10. maro

    maro Peon

    Messages:
    356
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #10
    seat it should be
    if ($number==1)
    without the quotes
     
    maro, Sep 19, 2005 IP
  11. seant

    seant Peon

    Messages:
    551
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #11
    hey,

    hmm..

    I put
    <?php
    $number=mt_rand(1, 2);
    if ($number==1) 
    {
    include "http://www.volconvo.com/adsense.txt"; 
    }
    else
    {
    include "http://www.volconvo.com/banners.txt"; 
    }
    ?>
    
    Code (markup):
    Into my header template in vbulletin where I want it to appear and it is blank. I thought by adding the http://www.volconvo.com/ location for the .txt files would help but it did not...

    I put the .txt files in both my /forums/ dir and my main dir because I was not sure where it would look for them. Still blank...

    Any ideas?
     
    seant, Sep 19, 2005 IP
  12. maro

    maro Peon

    Messages:
    356
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I am not very familiar with php but I think there is some include_path in the php settings or something like that... Maybe a php professional can help here
     
    maro, Sep 19, 2005 IP
  13. seant

    seant Peon

    Messages:
    551
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #13
    anyone?.......
     
    seant, Sep 21, 2005 IP