HTML
  Home arrow HTML arrow Page 2 - 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 - How drop down ads work


    (Page 2 of 7 )

    Before I discuss the database or PHP code for this article, let's take a quick look at how drop down ads actually work, so you know what I'm talking about. Let's assume that we have the following 430x50 banner on our web site:

    The top part of our drop down banner

    That banner's good, but what about if we could really grab our visitor's attention and provide them with more information about tomatoes, and also let them request a free taste sampling at the same time? Consider the second part of this banner, which is shown below:

    The bottom part of our drop down banner

    Now, if we took both of these banners and used a link with some JavaScript, we could display the top banner, and when the user click on a link, we could also display the bottom part of the banner:

    Both parts of our drop down banner

    In the image above, I've added the grey dotted line simply to show how the banners will appear. The [ Expand ] link above the banners can be used to toggle whether or not the bottom part of the banner is shown. As mentioned earlier, when the page loads, the bottom banner will be displayed for a couple of seconds and will then collapse, leaving only the top part of the banner visible, like this:

    The collapsed version of our banner

    Now, hopefully I haven't confused you too much and we can continue onto building the database that will hold the images and the details of each ad.

    Building the database
    To keep things simple, we will build a database that has just one table. Start by creating a database called ads at the MySQL console application:

    create database ads;
    use ads;


    Next we want to create a table that will store the details of each ad, as well as the top and bottom part of the banner, as blobs. Call the table banners:

    CREATE TABLE banners (
    bannerId int(11) NOT NULL auto_increment,
    title varchar(50) default NULL,
    width int(11) default NULL,
    type1 int(11) default NULL,
    type2 int(11) default NULL,
    data1 blob,
    data2 blob,
    link1 varchar(250) default NULL,
    link2 varchar(250) default NULL,
    numImps int(11) default '0',
    numClicks int(11) default '0',
    PRIMARY KEY (bannerId),
    UNIQUE KEY id (bannerId)
    ) TYPE=MyISAM;


    The banners table contains quite a few fields, so let's run through what each field is:
    • bannerId: A unique identifier for each banner.
    • title: A title by which the banner will be referenced, such as "My Banner".
    • width: The width of the banner. Both the top and bottom part of the banner must be the same width, and we will be using PHP's GetImageSize function to get the width of the banner.
    • type1: The MIME type of the top banner, such as image/gif.
    • type2: The MIME type of the bottom banner, such as image/gif.
    • data1: The top image stored as binary data.
    • data2: The bottom image stored as binary data.
    • link1: The link which the top banner will load when clicked.
    • link2: The link which the bottom banner will load when clicked.
    • numImps: The number of impressions for the banner.
    • numClicks: The number of clicks for the banner.
    As you can see, we are also tracking the number of impressions and click-thrus for each banner. We will create our drop down banner application and implementation using six files:
    • database.inc.php: Contains MySQL database connection details.
    • admin.php: Contains all functionality to add, remove and list banners currently stored in the database.
    • view.php: Contains one function called viewBanner. This function outputs the necessary HTML and JavaScript code to display an expandable/collapsible banner on the page.
    • getbanner.php: Accepts a query string value for the banner ID, sets appropriate content type headers, and streams the binary data for that banners image.
    • track.php: Whenever a banner is clicked, track.php increments the number of clicks field (numClicks) for that specific banner.
    • test.php: Calls up the viewBanner function of view.php, which shows a banner on the page, passing its ID as the only parameter.

    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 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek