Ad Rotator Script

Discussion in 'HTML & Website Design' started by mwgr5, Jul 7, 2007.

  1. #1
    I am using banner ads through an affiliate. I want be able to randomly display different merchant ads each time the page refreshes. So there would be one image, but each time the page refreshes a random merchant's ad would be displayed.

    What is the best way to do this?

    Thanks for the help!
     
    mwgr5, Jul 7, 2007 IP
  2. SEMSpot

    SEMSpot Peon

    Messages:
    513
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I setup a database in MySQL and had 3 fields. One for the banner number, one with the image name/location and the other for the link of the website for the banner. Then on the page or pages just set it up to pull a random banner number from the database and it will display it for you. I used this for a clients website who had 468x60 banners rotating on there website.

    
    <?php
    
    mysql_connect("localhost","username","password"); 
    mysql_select_db("dbname") or die("Unable to select database");
    
    $query = "SELECT * FROM banners ORDER BY RAND() LIMIT 0,1";
    $result = mysql_query($query) or die(mysql_error());
    
    mysql_close();
    while ($row = mysql_fetch_array($result))
    {echo "
    <a href=http://".$row["url"].">
    <img src=http://www.yourwebsite.com/images/banners/".$row["image"]." width=468 height=60></a>
    ";}
    
    ?>
    
    
    Code (markup):
     
    SEMSpot, Jul 7, 2007 IP
  3. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I use a script called hosting2nv ad rotator (I think you can find it on hotscripts.com) it works pretty good for me with CJ.com ads because I can enter them myself and you just include one IFrame in your page and it rotates them for you, it tracks the impressions, clicks, etc. and it is very easy to use. The only downside is that it doesn't handle/automate the purchase and display of ads from users (e.g. users buy ad space and it handles the paypal, then lets them upload their banner and it throws it into the rotation.) You could sell space and then enter the info yourself but it gets to be a but a a nuisance.

    It works great for CJ.com where you are just posting banners and not selling ad space though!

    Regards,
    Jeffrey

    (P.S. You can see it in action at: GameFun101.com
     
    jmhyer123, Jul 7, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It depends which server side language you are using.

    .Net has a built in component/ class for doing this
     
    AstarothSolutions, Jul 7, 2007 IP
  5. mwgr5

    mwgr5 Peon

    Messages:
    230
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I am using a blog on blogger, if that helps.
     
    mwgr5, Jul 7, 2007 IP