the-dream
08-28-2009, 11:16 AM
Hey Guys...
I run a small untargeted ad network, called Branchr Advertising...
I am currently coding a contextual advertising system, (code below) and I am wondering how I can make this more accurate, i.e. Generate a more relevant set of keywords for a given website/page.
<?php
function analyze($url, $output='array') {
// PAGE FUNCTIONS //
function strip_html_tags( $text )
{
$text = preg_replace(
array(
// REMOVE INVISIBLE CONTENT
'@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
'@<object[^>]*?.*?</object>@siu',
'@<embed[^>]*?.*?</embed>@siu',
'@<applet[^>]*?.*?</applet>@siu',
'@<noframes[^>]*?.*?</noframes>@siu',
'@<noscript[^>]*?.*?</noscript>@siu',
'@<noembed[^>]*?.*?</noembed>@siu',
// ADD LINE BREAKS AFTER BLOCKS
'@</?((address)|(blockquote)|(center)|(del))@iu',
'@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
'@</?((table)|(th)|(td)|(caption))@iu',
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
'@</?((frameset)|(frame)|(iframe))@iu',
),
array(
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
"\n\$0", "\n\$0",
),
$text );
return strip_tags( $text );
}
function removeCommonWords($input){
// CREATE AN ARRAY OF COMMON/BANNED WORDS
$commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after ','afterwards','again','against','ago','ahead','aint','all','allow','allows','almost','alone','along ','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and' ,'another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appea r','appreciate','appropriate','are','arent','around','as','as','aside','ask','asking','associated',' at','available','away','awfully','b','back','backward','backwards','be','became','because','become', 'becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside ','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot',' cant','cant','caption','cause','causes','certain','certainly','changes','clearly','cmon','co','co.', 'com','come','comes','concerning','consequently','consider','considering','contain','containing','co ntains','corresponding','could','couldnt','course','cs','currently','d','dare','darent','definitely' ,'described','despite','did','didnt','different','directly','do','does','doesnt','doing','done','don t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','e nd','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody ','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther ','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','fo rmerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting',' given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadnt','half','happe ns','hardly','has','hasnt','have','havent','having','he','hed','hell','hello','help','hence','her',' here','hereafter','hereby','herein','heres','hereupon','hers','herself','hes','hi','him','himself',' his','hither','hopefully','how','howbeit','however','hundred','i','id','ie','if','ignored','ill','im ','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','insi de','insofar','instead','into','inward','is','isnt','it','itd','itll','its','its','itself','ive','j' ,'just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latte rly','least','less','lest','let','lets','like','liked','likely','likewise','little','look','looking' ,'looks','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','maynt','me','m ean','meantime','meanwhile','merely','might','mightnt','mine','minus','miss','more','moreover','most ','mostly','mr','mrs','much','must','mustnt','my','myself','n','name','namely','nd','near','nearly', 'necessary','need','neednt','needs','neither','never','neverf','neverless','nevertheless','new','nex t','nine','ninety','no','nobody','non','none','nonetheless','noone','noone','nor','normally','not',' nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','oka y','old','on','once','one','ones','ones','only','onto','opposite','or','other','others','otherwise', 'ought','oughtnt','our','ours','ourselves','out','outside','over','overall','own','p','particular',' particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','pr ovided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','rec ently','regarding','regardless','regards','relatively','respectively','right','round','s','said','sa me','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems' ,'seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shant','s he','shed','shell','shes','should','shouldnt','since','six','so','some','somebody','someday','someho w','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','s pecify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','t h','than','thank','thanks','thanx','that','thatll','thats','thats','thatve','the','their','theirs',' them','themselves','then','thence','there','thereafter','thereby','thered','therefore','therein','th erell','therere','theres','theres','thereupon','thereve','these','they','theyd','theyll','theyre','t heyve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','th ree','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tr ied','tries','truly','try','trying','ts','twice','two','u','un','under','underneath','undoing','unfo rtunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','usef ul','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','want s','was','wasnt','way','we','wed','welcome','well','well','went','were','were','werent','weve','what ','whatever','whatll','whats','whatve','when','whence','whenever','where','whereafter','whereas','wh ereby','wherein','wheres','whereupon','wherever','whether','which','whichever','while','whilst','whi ther','who','whod','whoever','whole','wholl','whom','whomever','whos','whose','why','will','willing' ,'wish','with','within','without','wonder','wont','would','wouldnt','x','y','yes','yet','you','youd' ,'youll','your','youre','yours','yourself','yourselves','youve','z','zero', 'january','february','march','april','may','june','july','august','september','october','november',' december', 'dont', 'weve','theyre','comments','opinions', 'week', 'day', 'month', 'year', 'hour', 'min', 'minute', 'second', 'nbsp', 'newsnbsp', 'new', 'old', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ,'sunday', 'new', 'web', 'mark', 'michael', 'christian', 'bao', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec', 'gain', 'loss', 'move', 'isnt','good', 'bad', 'ok', 'okey', 'okay', 'jim', 'john', 'smith', 'bill', 'today', 'tomorrow', 'lot', 'lost', 'lots', 'companie', 'put', 'high', 'low', 'top', 'bottom');
return preg_replace('/\b('.implode('|',$commonWords).')\b/','',$input);
}
// END FUNCTIONS //
// GET THE 'TARGET' PAGE SOURCE AND PUT INTO THE $source VARIABLE.
$source = file_get_contents($url);
// USE OUR FUNCTION AND A STANDARD FUNCTION TO STRIP PAGE HTML.
$source = strip_tags(strip_html_tags($source));
// REMOVE ANY SPECIAL CHARACTERS
$source = preg_replace("/[^A-Za-z ]/","", $source);
// MAKE ALL WORDS LOWER CASE
$source = strtolower($source);
// REMOVE DISALLOWED WORDS
$source = removeCommonWords($source);
// SPLIT THE GROUP OF WORDS UP WHERE THERE IS A SPACE, PUT RESULT INTO AN ARRAY
$keywords = preg_split("/ /", $source);
foreach($keywords as $wordnum=>$keyword) {
// ENSURE THE KEYWORD ISN'T NOTHING
if($keyword != '') {
// ENSURE THE KEYWORD IS OVER 2 CHARS.
if(strlen($keyword) > 2) {
// INSURE THE KEYWORD IS LESS THAN OR EQUAL TO 10 CHARS
if(strlen($keyword) <= 10) {
// DE-PLURALIZE WORDS
if($keyword{strlen($keyword)-1} == 's') {
$keyword = substr($keyword, 0, -1);
}
// PUT FILTERED WORDS INTO A NEW ARRAY
$words[] = $keyword;
}
}
}
}
// COUNT THE TOTAL AMOUNT OF KEYWORDS
$tw = count($keywords);
// COUNT HOW MANY TIMES EACH WORD OCCURS AND PUT INTO ARRAY (word => count)
foreach($words as $wn=>$kw) {
$key[$kw] = $key[$kw] + 1;
}
foreach($key as $keywd=>$occurances) {
// ONLY INCLUDE WORDS THAT HAVE BEEN USED 3 TIMES ORE MORE
if($occurances >= 3) {
// GIVE EACH WORD A SCORE BASED ON IT'S OCCURANCES FROM THE TOTAL AMOUNT OF WORDS ON THE PAGE
$keyrank[$keywd] = round(100/$tw*$occurances, 3);
}
}
// SORT THE KEYWORDS ARRAY SO THE HIGHEST RANKED WORDS ARE AT THE TOP
arsort($keyrank, SORT_NUMERIC);
// CREATE AN ARRAY OF RESULTS
if($output == 'array') {
return $keyrank;
}
// CREATE A TABLE OF RESULTS
if($output == 'table') {
$results = '<table>';
$results .= '<tr><td><b><u>Keyword:</u></b></td><td><b><u>Rank:</u></b></td></tr>';
foreach($keyrank as $keyword=>$rank) {
$results .= '<tr><td><b>'.$keyword.'</b></td><td>'.$rank.'</td>';
}
$results .= '</table>';
return $results;
}
}
$url = $_GET['url'];
$siteKeywords = analyze($url);
// Top 30 Keywords
$count = 1;
foreach($siteKeywords as $keyword=>$rank) {
if($count <= 50) {
$kw[$keyword] = $rank;
$kwds .= "$keyword ";
} else {
break;
}
$count++;
}
$query = "SELECT * ,
match(text_1,text_2,keywords)
against ('$kwds')
as relevance
FROM
text_ads_test
WHERE
match(text_1,text_2,keywords) against ('$kwds')
ORDER BY relevance DESC";
$ads = mysql_query($query) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
body {
font-size: 13px;
font-family: "Helvetica Neue", Helvetica, Verdana, Arial, sans-serif;
}
.green {
color: #009f04;
}
.red {
color: #a90000;
}
</style>
<title>Branchr - Contextual Ad Targeting</title>
</head>
<body>
<?php
echo '<h2 style="padding: 0px; margin: 0px;">Branchr Contextual Ad Targeting</h2><hr /><b>The following ads are targeted to the content of:</b><br /><i>'.$url.'</i><br /><hr />';
$foundAds = mysql_num_rows($ads);
if($foundAds > 0) {
echo 'Status: <b class="green">Targeting Successful ('.$foundAds.' Relevant Ads)</b><br />Generated Keyword Set: <b>'.$kwds.'</b><hr />';
while($ad = mysql_fetch_array($ads)) {
echo "<b>".$ad['title']."</b> (Relevance: ".$ad['relevance'].")<br />".$ad['text_1']."<br />".$ad['text_2']."<br /><br />";
}
} else {
echo 'Status: <b class="red">Targeting Unsuccessful</b><br />Generated Keyword Set: <b>'.$kwds.'<hr />';
echo ':(';
}
?>
</body>
</html>
Thanks for you help!
P.S. If you run this code, you might want to remove the DB code, and have it just echo out a keyword set...
I run a small untargeted ad network, called Branchr Advertising...
I am currently coding a contextual advertising system, (code below) and I am wondering how I can make this more accurate, i.e. Generate a more relevant set of keywords for a given website/page.
<?php
function analyze($url, $output='array') {
// PAGE FUNCTIONS //
function strip_html_tags( $text )
{
$text = preg_replace(
array(
// REMOVE INVISIBLE CONTENT
'@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
'@<object[^>]*?.*?</object>@siu',
'@<embed[^>]*?.*?</embed>@siu',
'@<applet[^>]*?.*?</applet>@siu',
'@<noframes[^>]*?.*?</noframes>@siu',
'@<noscript[^>]*?.*?</noscript>@siu',
'@<noembed[^>]*?.*?</noembed>@siu',
// ADD LINE BREAKS AFTER BLOCKS
'@</?((address)|(blockquote)|(center)|(del))@iu',
'@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
'@</?((table)|(th)|(td)|(caption))@iu',
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
'@</?((frameset)|(frame)|(iframe))@iu',
),
array(
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
"\n\$0", "\n\$0",
),
$text );
return strip_tags( $text );
}
function removeCommonWords($input){
// CREATE AN ARRAY OF COMMON/BANNED WORDS
$commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after ','afterwards','again','against','ago','ahead','aint','all','allow','allows','almost','alone','along ','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and' ,'another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appea r','appreciate','appropriate','are','arent','around','as','as','aside','ask','asking','associated',' at','available','away','awfully','b','back','backward','backwards','be','became','because','become', 'becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside ','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot',' cant','cant','caption','cause','causes','certain','certainly','changes','clearly','cmon','co','co.', 'com','come','comes','concerning','consequently','consider','considering','contain','containing','co ntains','corresponding','could','couldnt','course','cs','currently','d','dare','darent','definitely' ,'described','despite','did','didnt','different','directly','do','does','doesnt','doing','done','don t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','e nd','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody ','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther ','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','fo rmerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting',' given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadnt','half','happe ns','hardly','has','hasnt','have','havent','having','he','hed','hell','hello','help','hence','her',' here','hereafter','hereby','herein','heres','hereupon','hers','herself','hes','hi','him','himself',' his','hither','hopefully','how','howbeit','however','hundred','i','id','ie','if','ignored','ill','im ','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','insi de','insofar','instead','into','inward','is','isnt','it','itd','itll','its','its','itself','ive','j' ,'just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latte rly','least','less','lest','let','lets','like','liked','likely','likewise','little','look','looking' ,'looks','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','maynt','me','m ean','meantime','meanwhile','merely','might','mightnt','mine','minus','miss','more','moreover','most ','mostly','mr','mrs','much','must','mustnt','my','myself','n','name','namely','nd','near','nearly', 'necessary','need','neednt','needs','neither','never','neverf','neverless','nevertheless','new','nex t','nine','ninety','no','nobody','non','none','nonetheless','noone','noone','nor','normally','not',' nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','oka y','old','on','once','one','ones','ones','only','onto','opposite','or','other','others','otherwise', 'ought','oughtnt','our','ours','ourselves','out','outside','over','overall','own','p','particular',' particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','pr ovided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','rec ently','regarding','regardless','regards','relatively','respectively','right','round','s','said','sa me','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems' ,'seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shant','s he','shed','shell','shes','should','shouldnt','since','six','so','some','somebody','someday','someho w','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','s pecify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','t h','than','thank','thanks','thanx','that','thatll','thats','thats','thatve','the','their','theirs',' them','themselves','then','thence','there','thereafter','thereby','thered','therefore','therein','th erell','therere','theres','theres','thereupon','thereve','these','they','theyd','theyll','theyre','t heyve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','th ree','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tr ied','tries','truly','try','trying','ts','twice','two','u','un','under','underneath','undoing','unfo rtunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','usef ul','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','want s','was','wasnt','way','we','wed','welcome','well','well','went','were','were','werent','weve','what ','whatever','whatll','whats','whatve','when','whence','whenever','where','whereafter','whereas','wh ereby','wherein','wheres','whereupon','wherever','whether','which','whichever','while','whilst','whi ther','who','whod','whoever','whole','wholl','whom','whomever','whos','whose','why','will','willing' ,'wish','with','within','without','wonder','wont','would','wouldnt','x','y','yes','yet','you','youd' ,'youll','your','youre','yours','yourself','yourselves','youve','z','zero', 'january','february','march','april','may','june','july','august','september','october','november',' december', 'dont', 'weve','theyre','comments','opinions', 'week', 'day', 'month', 'year', 'hour', 'min', 'minute', 'second', 'nbsp', 'newsnbsp', 'new', 'old', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ,'sunday', 'new', 'web', 'mark', 'michael', 'christian', 'bao', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec', 'gain', 'loss', 'move', 'isnt','good', 'bad', 'ok', 'okey', 'okay', 'jim', 'john', 'smith', 'bill', 'today', 'tomorrow', 'lot', 'lost', 'lots', 'companie', 'put', 'high', 'low', 'top', 'bottom');
return preg_replace('/\b('.implode('|',$commonWords).')\b/','',$input);
}
// END FUNCTIONS //
// GET THE 'TARGET' PAGE SOURCE AND PUT INTO THE $source VARIABLE.
$source = file_get_contents($url);
// USE OUR FUNCTION AND A STANDARD FUNCTION TO STRIP PAGE HTML.
$source = strip_tags(strip_html_tags($source));
// REMOVE ANY SPECIAL CHARACTERS
$source = preg_replace("/[^A-Za-z ]/","", $source);
// MAKE ALL WORDS LOWER CASE
$source = strtolower($source);
// REMOVE DISALLOWED WORDS
$source = removeCommonWords($source);
// SPLIT THE GROUP OF WORDS UP WHERE THERE IS A SPACE, PUT RESULT INTO AN ARRAY
$keywords = preg_split("/ /", $source);
foreach($keywords as $wordnum=>$keyword) {
// ENSURE THE KEYWORD ISN'T NOTHING
if($keyword != '') {
// ENSURE THE KEYWORD IS OVER 2 CHARS.
if(strlen($keyword) > 2) {
// INSURE THE KEYWORD IS LESS THAN OR EQUAL TO 10 CHARS
if(strlen($keyword) <= 10) {
// DE-PLURALIZE WORDS
if($keyword{strlen($keyword)-1} == 's') {
$keyword = substr($keyword, 0, -1);
}
// PUT FILTERED WORDS INTO A NEW ARRAY
$words[] = $keyword;
}
}
}
}
// COUNT THE TOTAL AMOUNT OF KEYWORDS
$tw = count($keywords);
// COUNT HOW MANY TIMES EACH WORD OCCURS AND PUT INTO ARRAY (word => count)
foreach($words as $wn=>$kw) {
$key[$kw] = $key[$kw] + 1;
}
foreach($key as $keywd=>$occurances) {
// ONLY INCLUDE WORDS THAT HAVE BEEN USED 3 TIMES ORE MORE
if($occurances >= 3) {
// GIVE EACH WORD A SCORE BASED ON IT'S OCCURANCES FROM THE TOTAL AMOUNT OF WORDS ON THE PAGE
$keyrank[$keywd] = round(100/$tw*$occurances, 3);
}
}
// SORT THE KEYWORDS ARRAY SO THE HIGHEST RANKED WORDS ARE AT THE TOP
arsort($keyrank, SORT_NUMERIC);
// CREATE AN ARRAY OF RESULTS
if($output == 'array') {
return $keyrank;
}
// CREATE A TABLE OF RESULTS
if($output == 'table') {
$results = '<table>';
$results .= '<tr><td><b><u>Keyword:</u></b></td><td><b><u>Rank:</u></b></td></tr>';
foreach($keyrank as $keyword=>$rank) {
$results .= '<tr><td><b>'.$keyword.'</b></td><td>'.$rank.'</td>';
}
$results .= '</table>';
return $results;
}
}
$url = $_GET['url'];
$siteKeywords = analyze($url);
// Top 30 Keywords
$count = 1;
foreach($siteKeywords as $keyword=>$rank) {
if($count <= 50) {
$kw[$keyword] = $rank;
$kwds .= "$keyword ";
} else {
break;
}
$count++;
}
$query = "SELECT * ,
match(text_1,text_2,keywords)
against ('$kwds')
as relevance
FROM
text_ads_test
WHERE
match(text_1,text_2,keywords) against ('$kwds')
ORDER BY relevance DESC";
$ads = mysql_query($query) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
body {
font-size: 13px;
font-family: "Helvetica Neue", Helvetica, Verdana, Arial, sans-serif;
}
.green {
color: #009f04;
}
.red {
color: #a90000;
}
</style>
<title>Branchr - Contextual Ad Targeting</title>
</head>
<body>
<?php
echo '<h2 style="padding: 0px; margin: 0px;">Branchr Contextual Ad Targeting</h2><hr /><b>The following ads are targeted to the content of:</b><br /><i>'.$url.'</i><br /><hr />';
$foundAds = mysql_num_rows($ads);
if($foundAds > 0) {
echo 'Status: <b class="green">Targeting Successful ('.$foundAds.' Relevant Ads)</b><br />Generated Keyword Set: <b>'.$kwds.'</b><hr />';
while($ad = mysql_fetch_array($ads)) {
echo "<b>".$ad['title']."</b> (Relevance: ".$ad['relevance'].")<br />".$ad['text_1']."<br />".$ad['text_2']."<br /><br />";
}
} else {
echo 'Status: <b class="red">Targeting Unsuccessful</b><br />Generated Keyword Set: <b>'.$kwds.'<hr />';
echo ':(';
}
?>
</body>
</html>
Thanks for you help!
P.S. If you run this code, you might want to remove the DB code, and have it just echo out a keyword set...