Home > Backend Development > PHP Tutorial > 如何查询表中一共有多少条数据

如何查询表中一共有多少条数据

WBOY
Release: 2016-06-13 10:06:40
Original
4115 people have browsed it

求助怎么查询表中一共有多少条数据
请问各位高手怎么查询数据库表中一共有多少条数据
麻烦帮写个例子
我是这么写的
$result=mysql_query("select count(*) from 表名");或是
$result=mysql_query("select * from 表名");
但是怎么才能把返回的结果 转成条数啊

------解决方案--------------------
$result=mysql_query("select count(*) as max from 表名");

$re = mysql_fetch_object($result);

$max = $re->max;

这个$max就是所有记录数
------解决方案--------------------
$result=mysql_query("select * from 表名");
$num_rows = mysql_num_rows($result);

这个也行

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