php判断数据库有几条数据的方法 1. 连接数据库; 2. 选择要查询的数据库; 3. 通过“select count(*) from tablename”语句查询数据库有几条数据即可。
本文操作环境windows7系统,php7.1版,dell g3电脑。
php怎么判断数据库有几条数据?
如果是客户端连接数据库的话,一条语句ok。
select count(*) from tablename;<?php$conn=mysql,connect('localhost','root','password');//连接数据库mysql,select,db('databasename',$conn);//选择要查询的数据库$sql=select count(*) from tablename;//sql查询语句if($result=mysql,query($sql,$conn)){$aaa=mysql,fetch,row($result);echo $aaa[0]; //输出表里面总记录数}