I have a MySQL keyword search on my website and it works fine. The problem is when someone searches a keyword I haven't added, nothing shows up on the results page.
Instead of nothing showing up I would like to have a no results found
message.
So I used the code below:
if (mysql_num_rows($Recordset1) > 0) {
// no results
echo 'No results found.';
} else {
do {
// output
} while($res = mysql_fetch_assoc($Recordset1));
}
The problem is whenever I search a keyword knowing it is in my db, I get my results along with a no results found
message. (The no results found
message also appears on the top left of my webpage pushing my entire website down.)
And when I searched a keyword I knew was not in my db, I didn't get a message at all, it showed nothing like before.
I played around with the greater, less than, and equal signs and got similar problems. I was told my logic was backwards, but I'm not sure how it should look.
Any help would be greatly appreciated, thanks in advance.