Home arrow HTML arrow Page 4 - Make Your Own Cool Drop Down Ad's

Make Your Own Cool Drop Down Ad's

"The age of the banner ad is dead" shouts a self-proclaimed online marketer. "Banner ads represent a bad return on investment" writes another. The truth of the matter is that banner ad's aren't dead, my friend. In this article Tim shows us how to create a banner management application that lets us add nifty MySQL-blobbed, two part drop-down banners to our sites. If you run your own site then you can't afford not to read this tutorial!

Author Info:
By: Tim Pabst
Rating: 4 stars4 stars4 stars4 stars4 stars / 26
May 20, 2002
  1. · Make Your Own Cool Drop Down Ad's
  2. · How drop down ads work
  3. · The admin.php script
  4. · The admin.php script (contd.)
  5. · Viewing, expanding and collapsing a banner
  6. · Tracking the number of click-thrus
  7. · Conclusion

print this article

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:

// Other options here

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:


if($row["numImps"] > 0)
echo number_format((($row["numClicks"] / $row["numImps"])*100), 2);
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.
<a href="admin.php">View Banners &gt;&gt;</a>
// 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.
<a href="javascript:history.go(-1)">&lt;&lt; Go Back</a>

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials