A client I'm creating a site for wants a custom advertising "engine". The plan is to have a few ads on the site and fill the rest with Google Adsense until all the spots are full.
My problem is how to determine which ad to dipslay. (Assume for now that I only have 1 ad placement.) My thinking was I'd have a table with:
- year
- month
- impressions for the month (0 for unlimited)
- used impressesion
- clients
- HTML code to display ad
I could do something like to get the ads:
SELECT *
FROM ad
WHERE impressions > used_impressions
OR impressesions = 0
ORDER BY RAND()
LIMIT 1
But, say I have 3 ads:
- 1 ad -- 5000 impressions
- 1 ad -- 5000 impressions
- Google Adsense filling the reaminder of the sites hits
Statistically speaking all 3 ads would be displayed an equal number of times. By the end of the first week and 15000 hits on the site, the first 2 ads would have used all of their impressions and the remaining 3+ weeks of the month and not be displayed again; only Google Adsense would be displayed.
How do I space out the ads so they are spread out over the month?
I am using LAMP.