Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Advertising --> Part 4: The BannerStats table

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
129 active users
1860 visitors today
2316 pages today
(only part of today)
Tools I use

CoverYourASP
Copyright © 1999-2010 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

The BannerStats table

In Part 3 we saw how BannerCounter.asp incremented the fields in the BannerStats table, but where did the record come in the first place? That's what we'll look at now.

Remember the BrandNewDay( ) function in utils/Init.asp that's called once per day or whenever we want to put the days banners into Application variables? That also has the following code in it:

// now create new entries in BannerStats table for today
for ( var i=0; i<nBanners; i++ )
{
   // see if it already exists
   DBGetRecords ( 'SELECT BannerID FROM BannerStats WHERE BannerDate=' + sDate + ' AND BannerID=' + nBannerIDs [ i ] );

   // create it if it doesnt exist
   if ( oRecordSet.EOF )
      oConnection.Execute ( 'INSERT INTO BannerStats (BannerDate,BannerID) VALUES (' + sDate + ',' + nBannerIDs [ i ] + ')' );
}

"nBanners" contains the number of banners that will be rotated through the day - for each banner I need to create a new record in the BannerStats table every day.

First I test if the record already exists for that banner and todays date. If it doesn't then I obviously create one. This code is called at the start of every day, and can also be called manually by me when adding new banners.

And that's that. From top to bottom, how I added advertising to CoverYourASP! Now you can do it too...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?