-1
$query = "SELECT * FROM XXXX";
$result = mysql_query($query);
$noOfRows = mysql_num_rows($result);

如何$result在得到结果之前检查是否为空mysql_num_rows

4

1 回答 1

1

您可以$result使用三元运算符检查 并设置$noOfRows0if 它是false

$query = "SELECT * FROM XXXX";
$result = mysql_query($query);
$noOfRows = (false===$result)? 0 : mysql_num_rows($result);
于 2012-10-27T01:55:20.457 回答