Please wait...
Popular Resources
Recent Forum Posts
Forum Signatures
26th-May-2012 10:33
martinlutherkingmemorialleparridefee
10th-May-2012 15:45
best ejpas
19th-Apr-2012 08:25
How To Securely Acquire Reproduction Watches Online
19th-Apr-2012 08:24
b0 hogan sito ufficiale
19th-Apr-2012 08:24
MBT Footwear: The Effortless Way to Supercharge Any Exercise Plan
19th-Apr-2012 08:23
Internet Speed
19th-Apr-2012 08:23
keyword ranking tool backlink service
19th-Apr-2012 08:22
favorites dgptp
19th-Apr-2012 08:21
handicap wheelchair lifts informations
19th-Apr-2012 08:21
Get MySQL Database size
Posted: 05-12-11 07:46
If you are creating statistics for your website, then your database size might be a good one to have. Showing the size of your MySQL database with PHP is easy with MySQLs built in Query. elow is the function to do so.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php function getDBSize() { $query = mysql_query( “SHOW TABLE STATUS” ); $size = 0; while( $row = mysql_fetch_array( $query ) ) { $size += $row["Data_length"]+$row["Index_length"]; } return number_format( (($size*1024)*1024), 2, '.', '' ) . "MB"; } ?>
The function above assumes you already have an open connection to your database. To use this function just call the getDBSize function and it will output something similar to: 34.56MB.
Enjoy!