If you're not managing the ads yourself, it's not possible to find out how often a certain ad has been displayed (only the number of overall displayed ads, which is equal to the hits).
If you're managing your own ads, I can only second what defiance said, get a pre-made script, they're powerful enough.
well, here's the thing, I am managing the the ads my self, the system I've come up with works as follows:
On the main page, there are 5 different ad-spots, each of these is an iframe witch loads a page called getad.php.
The getad.php script selects a random ad from the database witch matches the spot and the given time. then it updates the databaes with number of views+1 on the shown ad.
what do you think about this, is this a good solution or will this hammer the server as the number of hits increase? (two sql querys pr. show add, or 10 queryes pr. page hit)
By the way, I've taken a look at phpAdsNew, it looks a bit advanced and I there are a couple of extra features I'd like to incorporate into the system witch I couldn't find in phpAdsNew