完整的PHP代码如何写?
追答 亲,给你代码但是不保证能用啊,谁知道你的数据库怎么配置的
<?php
$conn = mysql_connect('localhost', 'root', '');
mysql_select_db('information_schema');
$target_db_name = 'test';
$sql = "select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='{$target_db_name}'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
print_r($row);
$db_host = 'localhost';//数据库主机地址
$db_user = 'root'; //帐号
$db_pass = 'root'; //密码
$db_name = 'db_name'; //数据库名
$db_info = 'db_info'; //数据表
<?php
$db_host = 'localhost';//数据库主机地址
$db_user = 'root'; //帐号
$db_pass = 'root'; //密码
$db_name = 'db_name'; //数据库名
$db_info = 'db_info'; //数据表
$conn = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db('information_schema');
$target_db_name = $db_name;
$sql = "select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='{$target_db_name}'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
print_r($row);
$sql = "select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='{$target_db_name}' and table_name='{$db_info}'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
print_r($row);
完整的PHP代码如何写?
$db_host = 'localhost';//数据库主机地址
$db_user = 'root'; //帐号
$db_pass = 'root'; //密码
$db_name = 'db_name'; //数据库名
$db_info = 'db_info'; //数据表