How to determine whether the query result is empty in php

coldplay.xixi
Release: 2023-03-05 18:36:01
Original
4683 people have browsed it

php method to determine whether the query result is empty: 1. Use the sql method, the code is [select count(people) c from people where people='Lele']; 2. Use the php method, the code is [$p=$_POST['p'];].

How to determine whether the query result is empty in php

[Related learning recommendations:php programming(video)]

php method to determine whether the query result is empty:

1,

select count(people) c from people where people='乐乐'
Copy after login

The above sql is the principle

2,

php utilization code

query("select count(people) c from people where people='".$p."'"); foreach($ps as $s){ if ($s['c']=='0'){ echo "用户可用"; }else{ echo "此用户名已存在"; } } ?>
Copy after login

If you want to learn more about programming, please pay attention to thephp trainingcolumn!

The above is the detailed content of How to determine whether the query result is empty in php. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!