Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?PHP
  2. $host = 'localhost';
  3. $user = 'root';
  4. $pass = '';
  5. $db = 'testdb';
  6.  
  7. $mysqli = new mysqli($host, $user, $pass, $db);
  8.  
  9. //show tables
  10. $result = $mysqli->query("SHOW TABLES from testdb");
  11. //print_r($result);
  12. while($tableName = mysqli_fetch_row($result))
  13. {
  14. $table = $tableName[0];
  15. echo '<h3>' ,$table, '</h3>';
  16. $result2 = $mysqli->query("SHOW COLUMNS from ".$table.""); //$result2 = mysqli_query($table, 'SHOW COLUMNS FROM') or die("cannot show columns");
  17. if(mysqli_num_rows($result2))
  18. {
  19. echo '<table cellpadding = "0" cellspacing = "0" class "db-table">';
  20. echo '<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>';
  21. while($row2 = mysqli_fetch_row($result2))
  22. {
  23. echo '<tr>';
  24. foreach ($row2 as $key=>$value)
  25. {
  26. echo '<td>',$value, '</td>';
  27. }
  28. echo '</tr>';
  29. }
  30. echo '</table><br />';
  31. }
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement