php统计数据库表多少行 php统计数据库表多少行数

php怎么统计mysql表里有多少数据,怎么把比如user里面的数据全部显示出来

$conn

成都创新互联成立与2013年,是专业互联网技术服务公司,拥有项目成都做网站、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元密云做网站,已为上家服务,为密云各地企业和个人服务,联系电话:18982081108

=

mysql_connect('localhost','root','123');

mysql_select_db('db_name');

//数据库名

mysql_query('set

names

utf8',$conn);

#$res

=

mysql_query('select

count(*)

from

user',$conn);

//统计user表里总共有多少条数据

#$res

=

mysql_query('select

*

from

user',$conn);

//把user里面的数据全部显示出来

$arr

=

array();

while($data

=

mysql_fetch_assoc($res))

{

$arr[]

=

$data;

}

print_r($arr);

可以依次把上面查询语句前面的注释去掉查看效果

PHP+MySQL如何统计数据库容量?

要想知道每个数据库的大小的话,步骤如下:

1、进入information_schema

数据库(存放了其他的数据库的信息)

use

information_schema;

2、查询所有数据的大小:

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables;

3、查看指定数据库的大小:

比如查看数据库home的大小

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables

where

table_schema='home';

4、查看指定数据库的某个表的大小

比如查看数据库home中

members

表的大小

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables

where

table_schema='home'

and

table_name='members';

php连接数据库服务器,然后选择使用的数据库名称为information_schema,然后执行查询就行了。看你问的这个问题应该不会不知道用php访问数据库吧。

如果你权限不够的话可能只能对特定的数据库的信息进行查询。

php怎么查询mysql里面表的数据总行数

?php

$sql = 'select count(*) as num from TableName';

$num = mysql_fetch_assoc(myslq_query($sql));#您可以简化该查询,如$db-XXX

$total = $num['num'];#$total即为行数

php如何查询某个表一共多少条记录?

需要准备的材料分别是:电脑、php编辑器、浏览器。

1、首先,打开php编辑器,新建php文件,例如:index.php。

2、在index.php中,输入代码:

$conn = new mysqli('10.5.15.177', 'root', '', 'test');

$sql = "select * from stu";

$r = $conn-query($sql);

print_r($r-num_rows);

3、浏览器运行index.php页面,此时打印出了stu表的记录数是5。

如何用PHP 查询及显示 mysql 数据库中某个表 的总行数?

$sql = mysql_query("select * from 表名");

$row = mysql_num_rows($sql);

echo $row;


本文标题:php统计数据库表多少行 php统计数据库表多少行数
网页地址:http://scyanting.com/article/docighc.html