Try this to get the size in bytes:
mysql_select_db("yourdatabase");
$q = mysql_query("SHOW TABLE STATUS");
$size = 0;
while($row = mysql_fetch_array($q)) {
$size += $row["Data_length"] + $row["Index_length"];
}
then convert to megabytes:
$decimals = 2;
$mbytes = number_format($size/(1024*1024),$decimals);
source
share