This is a keyword search script for one table only (pages). i need this search on 2 tables (pages and services) with one result set at the end to echo to the page. Can anyone help me? I have been trying to find a solution for 2 days - it would take too long to describe what I have already tried :) Thank you!
$todo=$_POST['todo'];
if(isset($todo) and $todo=="search"){
$search_text=$_POST['search_text'];
$type=$_POST['type'];
$bad_string = $search_text;
$bad_chars=array(',', '!', '.', 'ï','»','¿','â','¢','®');
$search_text=str_replace($bad_chars,'',$bad_string);
$search_text=ltrim($search_text);
$search_text=rtrim($search_text);
db_connect();
if($type<>"any"){
$query="select * FROM pages WHERE page_text='$search_text' ";
}else{
$kt=split(" ",$search_text);
while(list($key,$val)=each($kt)){
if($val<>" " and strlen($val) > 0){$q .= " page_text like '%$val%' or ";}
}
$q=substr($q,0,(strlen($q)-3));
$query="select * FROM pages where $q";
}
$result=mysql_query($query);
echo mysql_error();
$num_results = mysql_num_rows($result);
echo "<table cellspacing = 0 cellpadding = 10>";
while($row=mysql_fetch_array($result)){
$page_text = $row['page_text'];
$qid = $row['qid'];
$page_name = $row['page_name'];
echo "<tr><td>";
echo '* <u><a href="';
echo $page_name;
echo '.php">';
echo substr($row['page_text'],0,100);
echo '... *read more...</a></u><br><br>';
echo "</td></tr>";
}
echo "</table>";
}