[Advertising Script] keyword based advertising

Ok- I have a advertising php script that I code and sell. I’m always making improvements and adding new features to it.

Recently, I was asked about the ‘keyword based advertising’.

What I don’t know or clueless about is how does it works from the php programming side?

Is it possible to write a php code to somehow automatically scan/look/search the page for keyword(s) pulled from mysql?

Or would I have to manually setup ad codes like this:

http://www.domainname.com/ads/ad.php?c=1&k=keyword_does_here
SELECT * FROM ads WHERE id = '".sql_quote($id)."' AND status = 'active' AND credits > 0 AND camid = '".sql_quote($c)." AND `keywords` LIKE '%".$_GET['keyword']."%'

Ad #1- keywords: car, truck, bus
Ad #2- keywords: web, design, programming
Ad #3- keyword: (blank- meaning it will show on all pages)

If page has the word truck so ads with keyword ‘truck’ will show
If page have words ‘bus’, ‘web’ so ads with those keywords will show
If no matched keywords found on the page then random ads will show

Am I thinking right? The more I’m thinking about it, the more I get confused or lost.

I tried search Google for code info (how it works from programming side) but all I found was explaining how to use keyword based advertising for Google Adsense, Yahoo, blah blah unrelated.

This is ‘targeted advertising’ scanning the content of a page and choosing which ads to display on that page to relate to the content.

Keyword based advertising is the same thing, but the ads are generally shown on teh search results page of the search engine.

Your description fits, the more words you can match the more related the ad is to the content, in theroy