I am about to write an ad system and wanted to get some advice on a few things.
Basically my website will have several ad spots a page. For each ad spot there will be six ads that run in rotation.
I also need to track the number of views for these ads.
I am wondering how much of this I can combine query wise. My end goal would be to return a single ad row for each spot, and have the views column for the selected ads incremented.
My table will include...
id, ad_spot, view_count
If I query by the 'ad_spot' and total 'view_count' for the six rows returned, dividing by six and taking the remainder would tell me which of the ads should be used.
Is there any way to increment the view counts at the same time before returning to PHP?
How could I do the selection process in a query?
Would returning results for multiple ad_spots simply be a matter of doing a union of multiple queries?
Thanks for any advice!