I seem to be having problems with my search engine when a search is performed and no results are found. What I've been trying to do is to display a message saying "Sorry, no records found" when no record is found, but instead the page displays nothing. I think it might be a problem with the "if" statements, though I'm not sure. Can anybody help me?
Search script
-----------------------------------------
$db = mysql_connect("localhost","username","password" or die ("Could not connect to server"
mysql_select_db("username_db",$db) or die ("Could not connect to database"
$query = "SELECT * FROM celebdb WHERE search LIKE '%,$search,%' OR search LIKE '$search,%' OR search LIKE '%,$search'";
$result = mysql_query($query,$db);
if(!$result) {
printf("<tr><td bgcolor=aabbe5 class=contentbl>Sorry, no records found</td></tr>"
} else {
while ($myrow = mysql_fetch_array($result)) {
printf("<tr><td bgcolor=aabbe5 width=108 class=contentbl><a href=%s><img src=%s width=200 height=150 vspace=4 hspace=3></a></td><td bgcolor=bbccf5 class=contentbl width=390 valign=top height=85> <b>Name:</b> <a href=%s>%s</a><br><b>DOB:</b> %s<br><b>Feild:</b> %s<br><b>------------------------------------------------------</b><br><img src=../_images/spacer.gif width=30 height=5>%s</td></tr>", $myrow["fileloc"], $myrow["picloc"], $myrow["fileloc"], $myrow["name"], $myrow["dob"], $myrow["feild"], $myrow["desc"]);
Search script
-----------------------------------------
$db = mysql_connect("localhost","username","password" or die ("Could not connect to server"
mysql_select_db("username_db",$db) or die ("Could not connect to database"
$query = "SELECT * FROM celebdb WHERE search LIKE '%,$search,%' OR search LIKE '$search,%' OR search LIKE '%,$search'";
$result = mysql_query($query,$db);
if(!$result) {
printf("<tr><td bgcolor=aabbe5 class=contentbl>Sorry, no records found</td></tr>"
} else {
while ($myrow = mysql_fetch_array($result)) {
printf("<tr><td bgcolor=aabbe5 width=108 class=contentbl><a href=%s><img src=%s width=200 height=150 vspace=4 hspace=3></a></td><td bgcolor=bbccf5 class=contentbl width=390 valign=top height=85> <b>Name:</b> <a href=%s>%s</a><br><b>DOB:</b> %s<br><b>Feild:</b> %s<br><b>------------------------------------------------------</b><br><img src=../_images/spacer.gif width=30 height=5>%s</td></tr>", $myrow["fileloc"], $myrow["picloc"], $myrow["fileloc"], $myrow["name"], $myrow["dob"], $myrow["feild"], $myrow["desc"]);