0

I have code like this, it shows data when tehre is data but if there is no data i want to say "no records"

where am i going wrong?

<?php
require_once('db_conf.php');

$sql = "SELECT * FROM tbl_holidayspecials WHERE fld_country = '$countryname' AND fld_state = '$statename' AND fld_city = '$cityname'";
$result = mysql_query($sql);

if (!$result) {
  
echo "No Records";

}

while ($row = mysql_fetch_assoc($result)) {

		   $ids = $row["id"];
		   $hotelname = $row["fld_destination"];
	
echo $hotelname;
}
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by branding4you
0

use mysql_num_rows

if (mysql_num_rows($result) == 0) {
    echo "No records found";
}

Edited by R0bb0b: n/a

0

PERFECT !
Thank you it works I knew there was something to do with the rows it fetched.
Thank you again you dont know how much you helped

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.