HTML
  Home arrow HTML arrow Page 4 - Make Your Own Cool Drop Down Ad's
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Make Your Own Cool Drop Down Ad's
By: Tim Pabst
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2002-05-20

    Table of Contents:
  • Make Your Own Cool Drop Down Ad's
  • How drop down ads work
  • The admin.php script
  • The admin.php script (contd.)
  • Viewing, expanding and collapsing a banner
  • Tracking the number of click-thrus
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Make Your Own Cool Drop Down Ad's - The admin.php script (contd.)


    (Page 4 of 7 )

    After adding a banner, a confirmation message will be displayed in the browser, linking back to the list of banners. By calling admin.php without any query string value for method, the ShowBanners function is called:

    switch($_GET["method"])
    {
    // Other options here
    default:
    ShowBanners();
    }


    ShowBanners simply connects to our MySQL database and retrieves the bannerID, title, numImps and numClicks field for each banner from the banners table and displays them in a list. The ShowBanners function also works out the click-thru rate for each banner as well. Here's what admin.php output after I added two banners to the database:

    The ShowBanners function in action

    ShowBanners starts off by executing a SELECT statement against the banners table:

    $result = @mysql_query("select bannerId, title, numImps, numClicks from banners order by title asc");

    With the results from this select statement, a table containing rows of the banners is built. Dividing the number of clicks by the number of impressions and then multiplying that result by 100 works out the click-thru rate for each banner:

    <?php

    if($row["numImps"] > 0)
    {
    echo number_format((($row["numClicks"] / $row["numImps"])*100), 2);
    }
    else
    {
    echo "0";
    }
    ?>%


    The click-thru rate of a banner is typically measured as a percentage compared to the number of impressions, so we use the number_format function to format the result with two decimal places.

    If you noticed the screenshot of the ShowBanner function above, then you would've seen the "Remove" link next to each banner. The remove link points to admin.php?method=delete&bannerId=xxx, which means that the DeleteBanner function is called, passing in the bannerId query string as its only parameter:

    function DeleteBanner($BannerId)

    DeleteBanner connects to the database and executes an SQL DELETE command against the banners table, removing the banner whose bannerId field is $BannerId:

    if(@mysql_query("delete from banners where bannerId = $BannerId"))
    {
    // Query OK, banner has been deleted
    ?>
    <h2>Banner Deleted</h2>
    Your banner has been successfully deleted a banner from the database. Use
    the link below to goto the list of banners.
    <br><br>
    <a href="admin.php">View Banners &gt;&gt;</a>
    <?php
    }
    else
    {
    // Query failed
    ?>
    <h2>An Error Occured</h2>
    An error occured while trying to delete the selected banner
    database. Use the link below to try again.
    <br><br>
    <a href="javascript:history.go(-1)">&lt;&lt; Go Back</a>
    <?php
    }

    More HTML Articles
    More By Tim Pabst


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek