Guest User

Untitled

a guest
Mar 1st, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5.  
  6. /* DB Information */
  7. $name = ''; //db name
  8. $user = ''; //user name
  9. $pass = ''; //password
  10. $host = ''; //host
  11. /* DB Information */
  12.  
  13. $connect = mysqli_connect($host, $user, $pass, $name);
  14. if (mysqli_connect_errno()) {
  15. echo '<b>CONNECTION FAILED:</b> ' . mysqli_connect_error();
  16. } else {
  17. echo '<b>CONNECTION SUCCESS!</b></br></br><u>TABLES</u></br>';
  18.  
  19. // Table names and columns.
  20. $test_query = "SHOW TABLES FROM $name";
  21. $result = mysqli_query($connect, $test_query);
  22. $tables = 0;
  23.  
  24. while($tbl = mysqli_fetch_array($result)) {
  25. $tables++;
  26. echo '</br>' . $tbl[0] . '</br>';
  27. $test_column = "SHOW COLUMNS FROM $tbl[0]";
  28. $column_result = mysqli_query($connect, $test_column);
  29. while($col = mysqli_fetch_array($column_result)) {
  30. echo ' "' . $col[0] . '" ';
  31. }
  32. echo '</br>';
  33. }
  34.  
  35. if (!$tables) {
  36. echo 'Table Not Found.</br>';
  37. } else {
  38. echo '</br><em>Total ' . $tables . ' Tables</em></br>';
  39. }
  40. }
Add Comment
Please, Sign In to add comment