首页 > 代码库 > php 判断查询结果是否为空

php 判断查询结果是否为空

select count(people) c from people where people=‘乐乐‘

上面这条sql就是原理

技术分享

技术分享

php利用代码

 

<?php $p=$_POST[‘p‘];$cnx = new PDO("odbc:Driver={SQL Server};Server=;Database=;",‘‘,‘‘);$ps=$cnx->query("select count(people) c from people where people=‘".$p."‘");foreach($ps as $s){if ($s[‘c‘]==‘0‘){echo "用户可用";}else{echo "此用户名已存在";}} ?>

 

  

php 判断查询结果是否为空