如何檢查mysql結果是否爲空。如果mysql查詢結果爲空,則不應排除其他情況。 如果mysql結果數據有&其他條件我的錯誤我的消息在那裏,但它沒有顯示任何錯誤消息。 我試過下面的代碼,但沒有在屏幕上顯示任何警報或回聲消息。如何檢查MySQL結果是否在PHP中返回空?
<?php
$sql = "select * from hall_search_data_1 where rent BETWEEN '".$_SESSION['amount1']."' AND '".$_SESSION['amount2']."'";
$res = mysql_query($sql);
if(!empty($res)){
while($row=mysql_fetch_row($res))
{
// here my data
}
}else{
echo "no results found";
echo "<br>";
echo "<script>alert('No any result found..!!');</script>";
echo "no results found";
}
?>