Quickly count the data volume of each table in a database through PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:16:29
Original
968 people have browsed it

So I simply wrote a few lines of code to achieve the above requirements

Execution results:


Copy code The code is as follows:

$conn=mysql_connect('localhost','root','');
mysql_select_db('database',$conn);
$sql="SELECT information_schema.TABLES.TABLE_NAME FROM information_schema. TABLES WHERE table_schema = 'database'";
$res=mysql_query($sql);
while ($result = mysql_fetch_assoc($res) ) {
$tables[]=$result['TABLE_NAME'];
};
echo "


< ;td>Table name

";
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 "';
}
echo "
Data volume
".$result_count[$v].''.$result_count['nums']. '
"
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325888.htmlTechArticleSo I simply wrote a few lines of code to achieve the above requirements and the execution results: Copy the code as follows: ?php $ conn=mysql_connect('localhost','root',''); mysql_select_db('database',...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template