原始效果
--------------------------------------------------
数据库总量:
490766329
数据库大小:
25115924452
---------------------------------------------------
要达到的效果
数据库总量:
4.90亿条
数据库大小:
23.39 GB 
   关键代码$e=0;
$count=mysql_query("select table_name from information_schema.tables where table_schema='data'");   
while($rows=mysql_fetch_array($count)){
$c= $rows['table_name'];
$count_table=mysql_query("select count(*) from  $c");
while(@$d=mysql_fetch_array($count_table)){
$e= $e+($d['count(*)']);

}
}
?><div id="stats-submit-date" style="float:left">数据库总量:</div>
              
              <div class="">
                <span id="stats-views" class="stat"><?php echo $e;?></> </span>亿条
              </div>
              <div class="clear"></div>
              <div id="stats-submit-date" style="float:left">占用空间:</div>
              
              <div class="">
                <span id="stats-views" class="stat">23.39</span>GB
后面的GB没定义 请帮忙弄下 谢谢了
参考代码 http://www.douban.com/note/139003240/

解决方案 »

  1.   

    只会用笨办法了;$a = 490766329;
    $b = 25115924452;
    echo number_format(floor($a*pow(10, -6))*pow(10, -2),2);
    echo number_format($b/pow(1024,3),2).'GB';
      

  2.   

    $sql = "select sum(TABLE_ROWS) as 记录数, sum(DATA_LENGTH+INDEX_LENGTH) as 占用空间 from information_schema.tables where table_schema='data'";
    $rs = mysql_query($sql);
    print_r(mysql_fetch_assoc($rs));