加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

通过php快速统计某个数据库中每张表的数据量

发布时间:2020-12-13 06:09:41 所属栏目:PHP教程 来源:网络整理
导读:所以自己简单写了几行代码用来实现以上需求 执行结果: IMG alt="" src="https://files.jb51.cc/file_images/article/201209/201209042218202.png"gt;div class="codetitle" a style="CURSOR: pointer" data="24634" class="copybut" id="copybut24634" oncl

<tr>
<td>表名</td>
<td>数据量</td>
</tr>";
foreach ($tables as $k=>$v){
$sql_count="select count(id) AS nums,'".$v."' from ".$tables[$k];
$res_count=mysql_query($sql_count);
$result_count = mysql_fetch_assoc($res_count);
echo "<tr><td>".$result_count[$v].'</td><td>'.$result_count['nums'].'</td></tr>';
}
echo "</table>"
?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

所以自己简单写了几行代码用来实现以上需求 执行结果:

<IMG alt="" src="https://files.52php.cn/file_images/article/201209/201209042218202.png"&gt;<div class="codetitle">

<a style="CURSOR: pointer" data="24634" class="copybut" id="copybut24634" onclick="doCopy('code24634')"> 代码如下:<div class="codebody" id="code24634">
<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('数据库',$conn);
$sql="SELECT information_schema.TABLES.TABLE_NAME FROM information_schema. TABLES WHERE table_schema = '数据库'";
$res=mysql_query($sql);
while ($result = mysql_fetch_assoc($res)) {
$tables[]=$result['TABLE_NAME'];
};
echo "<table>
    推荐文章
      热点阅读