hi everyone,
I've written some code that displays information from a database. However, I added more code that would display a "no records found" message, should the area be blank.
The code displays the records perfectly, however if there are no records returned it doesn't show the "no records found" message.
Can someone please have a quick look and tell me where I'm going wrong? I know it's going to be something simple, but that just makes it even worse!!!
Thanks guys :)
<?php
mysql_connect(HOST,USER,PASS);
@mysql_select_db("db303278079") or die( "Unable to select database");
$query="select * from ".RECORDS." WHERE area='manchester' order by link_text ASC";
$result=mysql_query($query);
$num=mysql_num_rows($result);
for ($i=0; $i<$num; $i++) {
$rest_name=mysql_result($result,$i,"link_text");
$address=mysql_result($result,$i,"address");
$telephone=mysql_result($result,$i,"telephone");
$website=mysql_result($result,$i,"url");
$cuisine_type=mysql_result($result,$i,"cuisine_type");
$area=mysql_result($result,$i,"area");
$website=(empty($website))?'':", <strong><A HREF=$website>Website</a></strong>";
$count = @mysql_num_rows($result);
if($count > 0)
{
echo "<strong>$rest_name</strong>, $address, $telephone, ($cuisine_type)$website<br><br >";
}
else
{
echo "no records found";
}
mysql_close();
}
?>