Advertisement
Guest User

teosu

a guest
Mar 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.26 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Tables from MySQL Database</title>
  6.  
  7. <style type="text/css">
  8. table.db-table      { border-right:1px solid #ccc; border-bottom:1px solid #ccc; }
  9. table.db-table th   { background:#eee; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }
  10. table.db-table td   { padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }
  11. </style>
  12.  
  13. </head>
  14. <body>
  15.  
  16. <?php
  17. /* connect to the db */
  18. $connection = new mysqli('localhost','root','', 'atestat');
  19.  
  20.  
  21. /* show tables */
  22. $result = mysql_query('SHOW TABLES',$connection) or die('cannot show tables');
  23. while($tableName = mysql_fetch_row($result)) {
  24.  
  25.     $table = $tableName[0];
  26.    
  27.     echo '<h3>',$table,'</h3>';
  28.     $result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('cannot show columns from '.$table);
  29.     if(mysql_num_rows($result2)) {
  30.         echo '<table class="db-table" cellpadding="0" cellspacing="0"><thead><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr></thead><tbody>';
  31.         while($row2 = mysql_fetch_row($result2)) {
  32.             echo '<tr>';
  33.             foreach($row2 as $key=>$value) {
  34.                 echo '<td>',$value,'</td>';
  35.             }
  36.             echo '</tr>';
  37.         }
  38.         echo '</tbody></table><br>';
  39.     }
  40. }
  41. ?>
  42.  
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement