PHP循环输出指定数据库中的表名及行数等相关信息
更新:2022-04-16 18:45:45
人气:895
来源:本站原创
A+
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>
推荐的文章
随手记
- ● 统信UOS开机指定网址全屏启动自带浏览器以及屏蔽ALT+F4关闭
- ● xshellSSH连接Linux服务器防止超时退出
- ● php8开启OpenSSL扩展库报错disabledinstallext
- ● 统信系统linux安装php时的报错libxml-2.0>=2.7.6
- ● tidb关闭sql_mode=ONLY_FULL_GROUP_BY模式
- ● windows10如何开机自动运行bat文件
- ● Win10Mysql8初始密码丢失,初始化又不显示密码
- ● UOS系统关闭防火墙或者放行tcp80端口
- ● 统信系统UOS纯命令行与图形模式界面桌面切换方法
- ● javascript(js)的小数点乘法除法问题详解
PHP经验分享
- ● PHP代码用UDP方式远程唤醒电脑让计算机开机
- ● apache下php生成验证码图片不能显示
- ● PHP使用AES加密解密示例(无偏移)
- ● Pluginmysql_native_passwordreported:''mysql_native_password'isdeprecate问题
- ● PHP实现计算CRC-16/MODBUS校验位
- ● MySQLSUM在没有符合查询条件时返回结果为空的处理办法
- ● 如何开启PHP8的JIT提升运行速度
- ● 钉钉API接口-用PHP+Curl实现获取用户信息
- ● 钉钉API接口-用PHP+Curl实现获取应用Access_Token
- ● 在PHP中使用CURL,“撩”服务器只需几行——phpcurl详细解析和常见大坑