Home >Backend Development >PHP Problem >How does php determine whether the mysql query result is empty?
php method to determine whether the mysql query result is empty: 1. Query through the "if (mysql_num_rows($rows) < 1){...}" method; 2. Query through "if(!mysql_affected_rows( )){...}" method query.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php determine whether the mysql query result is null?
php determines whether the query result of the SQL statement is empty
determines whether the result set of the SQL statement query is empty!
<?php //方法一 获取select结果集的行数 $rows=mysql_query("select * from `student` where `age`='16';"); if (mysql_num_rows($rows) < 1){ echo '查询无数据!'; } //方法二 返回上一次操作受影响的行数 $rows=mysql_query("select * from `student` where `age`='16';"); if(!mysql_affected_rows()){ echo '查询无数据!'; } ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How does php determine whether the mysql query result is empty?. For more information, please follow other related articles on the PHP Chinese website!