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?


$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;

Recommended Answers

All 2 Replies

use mysql_num_rows

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.