I'm using the following code to excute a search query, everything seems to work fine except it returns one object short, meaning if I had 2 articles with the word "test" in the title, it only returns the later one, if there was only one article with the title "test" then it doesn't return anything. I remember something about this being a problem with while loops, I'm nto sure if this is the case cuz I've seen many search examples using while loops and no one complained about my problem. Any help would be appreciated:
if($cat_id=="all"){
$search_query = "SELECT * FROM news WHERE (title LIKE '%$keyword%') OR (summary LIKE '%$keyword%') OR (content LIKE '%$keyword%') ";
$search_result = mysql_query($search_query);}
else {$search_query = "SELECT * FROM news WHERE ((title LIKE '%$keyword%') OR (summary LIKE '%$keyword%') OR (content LIKE '%$keyword%')) AND (cat_id=$cat_id) ";
$search_result = mysql_query($search_query);}
if(mysql_fetch_object($search_result)=="0"){echo"<table><tr><td>No results found</td></tr></table>";}
else{
while($row=mysql_fetch_object($search_result)) {
$artitle=$row->title;
$arnews_id=$row->news_id;
$arsummary=$row->summary;
$photot=$row->photo;
$arcat_id=$row->cat_id;
echo"<table><tr><td>$artitle<br></td></tr></table>";
}
mysql_free_result($search_result);
}