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...
Comments