PHP循环输出指定数据库中的表名及行数等相关信息
PHP循环输出指定数据库中的表名及行数等相关信息,第一步获取指定数据库中的表名,生成数组。
$sql_status=" SHOW TABLE STATUS FROM 数据库名"; if ($result=$mysqli->query($sql_status)){ while ($rs=$result->fetch_array()){ //用数组 $tables_row[]=$rs; } }else{ echo "Error"; exit; }
将数据库中的表名列表数组,用PHP循环输出显示出数据库中数据表的信息
<table width="100%"> <thead> <tr> <td colspan="9" align="center" style="font-size:24px;" >数据库优化及状态信息</td> </tr> </thead> <tr> <td width="12%" height="65" align="center" ><strong> 表的名<br /> Name</strong></td> <td width="9%" height="65" align="center" ><strong> 存储引擎 <br /> Engine</strong></td> <td width="7%" height="65" align="center" ><strong> 行数 <br /> Rows</strong></td> <td width="13%" height="65" align="center" ><strong> 数据文件的长度 <br /> Data_length</strong></td> <td width="11%" height="65" align="center" ><strong> 索引长度 <br /> Index_length</strong></td> <td width="11%" height="65" align="center" ><strong> Auto_increment</strong></td> <td width="16%" height="65" align="center" ><strong>Update_time</strong></td> <td width="11%" height="65" align="center" ><strong> 字符集和整序 <br /> Collation</strong></td> <td width="10%" height="65" align="center" ><strong> 评注<br /> Comment</strong></td> </tr> <? //print_r($tables_row); $i=0; foreach($tables_row as $value_row){ $mysqli->query ("optimize table ".$value_row[0]." ");//优化各个表 $i++; ?> <tr> <td height="35" align="center" ><?=$value_row[0]?></td> <td height="35" align="center" ><?=$value_row[1]?></td> <td height="35" align="center" ><?=$value_row[4]?></td> <td height="35" align="center" ><?=$value_row[6]?></td> <td height="35" align="center" ><?=$value_row[8]?></td> <td height="35" align="center" ><?=$value_row[10]?></td> <td height="35" align="center" ><?=$value_row[12]?></td> <td height="35" align="center" ><?=$value_row[14]?></td> <td height="35" align="center" ><?=$value_row[17]?></td> </tr> <? } ?> </table>
相关内容
这些是最新的
热门排行
- THINKPHP5+GatewayWorker+Workerman 开发在线客服系统
- 在手机浏览器网页中点击链接跳转到微信界面的方法
- 尊云网站目录系统 ThinkPHP5网站分类目录程序 v2.2.221011
- CentOS 7安装shadowsock(一键安装脚本)
- AdminTemplate 基于LayUI 2.4.5实现的网站后台管理模板
- 用NW.js(node-webkit)开发多平台的桌面客户端
- PHP生成随机昵称/用户名
- THINKPHP5网站分类目录程序 尊云网站目录系统
- 织梦(DEDECMS)微信支付接口 微信插件
- 基于LayUI开发的 网站后台管理模板 BeginnerAdmin
- 响应式后台网站模板 - AMA.ADMIN
- layuiAdmin后台管理模板 Iframe版
- LayUI 1.0.9 升级 至 LayUI 2.1.4 方法
- 简洁清爽的会员中心模板
- jQuery幸运大转盘抽奖活动代码