I have a search engine that lists recent search queries, and I want to filter a list of words from the results:
<?
function format_term($term) {
$term = str_replace('-','~~',$term);
return str_replace(' ','-',$term);
}
$res = mysql_query("SELECT * FROM $querytable ORDER BY q_id DESC") or die(mysql_error());
$bad_words = array('words.txt');
$pattern = '%'.preg_quote(implode('|', $bad_words)).'%i';
if (preg_match($pattern, $searchstring)) {
do_insert();
}
while (($line = mysql_fetch_assoc($res)) && strlen(ob_get_contents()) < 95*1024) {
echo "<a href='".constant('dir')."search/".format_term($line['q_query'])."'>".$line['q_query']."</a><br>";
}
?>
</div>
I am a bit lost in how to do this. Any help would be most appreciated.