Error in search code for forum...
Posted: Fri Oct 15, 2004 5:10 pm
It doesn't show error, it just shows all the posts instead of the ones that actually contain the search results...
The code
The code
Code: Select all
<?php
// Words commonly used...
$look = str_replace(" a "," ",$look);
$look = str_replace(" the "," ",$look);
$look = str_replace(" and "," ",$look);
$search = explode(" ",$look);
// I want to make sure it finds a word, not part of a word...
$x = 0;
foreach($search as $searchstr){
$search[$x] = " $searchstr ";
$x = $x+1;
}
$q = "SELECT * FROM mbposts";
$do = mysql_db_query($db,$q);
while($post=mysql_fetch_array($do)){
foreach($search as $value){
$check = strrpos($post[post],$value);
if($check){
$disb = strrpos($disbe,$post[topic]);
if(!$disb){
$disbe.=" $post[topic] ";
$found = "yes";
echo"<tr><td><a href="index.php?mode=topic&f=$post[forum]&topic=$post[topic]">$post[topic]</a></td><td>On: $post[date]</tr>";
}
}
}
}
if($found!="yes"){
echo"Sorry, no results were found";
}
?>