Advertisement
Guest User

Untitled

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