Advertisement
Guest User

Untitled

a guest
May 15th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <style>
  2. * {
  3. font-size: 14px;
  4. font-family: "Roboto", Arial, sans-serif;
  5. margin-bottom: 0px;
  6. }
  7. table {
  8. margin: 0 auto;
  9. text-align: left;
  10. border-collapse: collapse;
  11. border: 1px solid #aaaaaa;
  12. }
  13.  
  14. tr:nth-child(even) {
  15. background: #eeeeee;
  16. }
  17.  
  18. th, td {
  19. padding: 10px 30px;
  20. }
  21.  
  22. th {
  23. border-bottom: 1px solid #aaaaaa;
  24. }
  25. </style>
  26. <?php
  27.  
  28. $host = "localhost";
  29. $database = "information_schema";
  30. $username = "root";
  31. $password = "root";
  32.  
  33. $sSql = <<<SQL
  34. SELECT
  35. table_schema 'Data Base Name',
  36. sum( data_length + index_length ) / 1024 / 1024 'Data Base Size in MB',
  37. sum( data_free ) / 1024 / 1024 'Free Space in MB'
  38. FROM
  39. information_schema.TABLES
  40. GROUP BY
  41. table_schema
  42. SQL;
  43.  
  44. try
  45. {
  46. $dsn = "mysql:host=" . $host . ";dbname=" . $database;
  47. $conn = new PDO( $dsn, $username, $password );
  48.  
  49. $stmt = $conn->prepare( $sSql );
  50. $stmt->execute();
  51.  
  52. echo "<table>";
  53. echo "<tr><th colspan=3>Database [" . $host . "] Connected</th></tr>";
  54. echo "<tr>";
  55. echo "<th>Database Name</th>";
  56. echo "<th>Size (Mb)</th>";
  57. echo "<th>Free (Mb)</th>";
  58. echo "</tr>";
  59. while( $row = $stmt->fetch( PDO::FETCH_ASSOC ) )
  60. {
  61. echo "<tr>";
  62. foreach( $row as $value )
  63. {
  64. echo sprintf( "<td>%s</td>", $value );
  65. }
  66. echo "</tr>";
  67. }
  68. echo "</table>";
  69. }
  70. catch( PDOException $e )
  71. {
  72. die( "<h1>" . $e->getMessage() . "</h1>" );
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement