How does php determine whether the mysql query result is empty?

藏色散人
Release: 2023-03-11 18:54:01
Original
4510 people have browsed it

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.

How does php determine whether the mysql query result is empty?

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`=&#39;16&#39;;");
if (mysql_num_rows($rows) < 1){
echo &#39;查询无数据!&#39;;
}
//方法二 返回上一次操作受影响的行数
$rows=mysql_query("select * from `student` where `age`=&#39;16&#39;;");
if(!mysql_affected_rows()){
    echo &#39;查询无数据!&#39;;
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template