Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- * {
- font-size: 14px;
- font-family: "Roboto", Arial, sans-serif;
- margin-bottom: 0px;
- }
- table {
- margin: 0 auto;
- text-align: left;
- border-collapse: collapse;
- border: 1px solid #aaaaaa;
- }
- tr:nth-child(even) {
- background: #eeeeee;
- }
- th, td {
- padding: 10px 30px;
- }
- th {
- border-bottom: 1px solid #aaaaaa;
- }
- </style>
- <?php
- $host = "localhost";
- $database = "information_schema";
- $username = "root";
- $password = "root";
- $sSql = <<<SQL
- SELECT
- table_schema 'Data Base Name',
- sum( data_length + index_length ) / 1024 / 1024 'Data Base Size in MB',
- sum( data_free ) / 1024 / 1024 'Free Space in MB'
- FROM
- information_schema.TABLES
- GROUP BY
- table_schema
- SQL;
- try
- {
- $dsn = "mysql:host=" . $host . ";dbname=" . $database;
- $conn = new PDO( $dsn, $username, $password );
- $stmt = $conn->prepare( $sSql );
- $stmt->execute();
- echo "<table>";
- echo "<tr><th colspan=3>Database [" . $host . "] Connected</th></tr>";
- echo "<tr>";
- echo "<th>Database Name</th>";
- echo "<th>Size (Mb)</th>";
- echo "<th>Free (Mb)</th>";
- echo "</tr>";
- while( $row = $stmt->fetch( PDO::FETCH_ASSOC ) )
- {
- echo "<tr>";
- foreach( $row as $value )
- {
- echo sprintf( "<td>%s</td>", $value );
- }
- echo "</tr>";
- }
- echo "</table>";
- }
- catch( PDOException $e )
- {
- die( "<h1>" . $e->getMessage() . "</h1>" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement