Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$query = "SELECT * FROM XXXX"; $result = mysql_query($query); $noOfRows = mysql_num_rows($result);
如何$result在得到结果之前检查是否为空mysql_num_rows?
$result
mysql_num_rows
您可以$result使用三元运算符检查 并设置$noOfRows为0if 它是false:
$noOfRows
0
false
$query = "SELECT * FROM XXXX"; $result = mysql_query($query); $noOfRows = (false===$result)? 0 : mysql_num_rows($result);