Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<html><head><title>MySQL Database size</title></head><body>
<h1>MySQL Database size</h1>
<?php
function file_size_info($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
$file_size_info['size'] = ceil($filesize);
$file_size_info['type'] = $bytes[$i];
return $file_size_info;
}
$db_server = 'localhost';
$db_user = 'root';
$db_pwd = 'toor';
$db_name = 'onlineshop';
$db_link = @mysql_connect($db_server, $db_user, $db_pwd)
or exit('Could not connect: ' . mysql_error());
$db = @mysql_select_db($db_name, $db_link)
or exit('Could not select database: ' . mysql_error());
// Calculate db size by adding table size + index size:
$rows = mysql_query("SHOW TABLE STATUS");
$dbsize = 0;
while ($row = mysql_fetch_array($rows)) {
$dbsize += $row['Data_length'] + $row['Index_length'];
}
print "Database size is: $dbsize bytes<br />";
print 'or<br />';
$dbsize = file_size_info($dbsize);
print "Database size is: {$dbsize['size']} {$dbsize['type']}";
?>
</body></html>
<?php
$link = mysql_connect('localhost', 'root', 'toor');
$db_name = "onlineshop";
$tables = array();
mysql_select_db($db_name, $link);
$result = mysql_query("SHOW TABLE STATUS");
while($row = mysql_fetch_array($result)) {
/* We return the size in Kilobytes */
$total_size = ($row[ "Data_length" ] +
$row[ "Index_length" ]) / 1024;
$tables[$row['Name']] = sprintf("%.2f", $total_size).' KiB<br>';
$a += $total_size/1024;
}
print_r($tables);
print 'Total:'.number_format($a,2).'MB';
?>
JimBeam каза:Rotatora +
Joroo на мен ми трябва като пхп файл понеже по бърз остава ..