Guest User

Untitled

a guest
Feb 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?php
  2. $dbname = 'shop';
  3. $dbuser = 'john';
  4. $dbpass = 'john_password';
  5. $dbhost = db_server;
  6. $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
  7. // Check connection
  8. if ($conn->connect_error) {
  9. die("Connection failed: " . $conn->connect_error);
  10. }
  11. $sql = "SHOW TABLES FROM $dbname";
  12. $result = $conn->query($sql);
  13. $tblCnt = 0;
  14. if ($result->num_rows > 0) {
  15. // output data of each row
  16. while($row = $result->fetch_assoc()) {
  17. $tblCnt++;
  18. echo $row[0]."<br \>\n";
  19. }
  20. }
  21. if (!$tblCnt) {
  22. echo "There are no tables<br \>\n";
  23. } else {
  24. echo "There are $tblCnt tables<br \>\n";
  25. }
  26. $conn->close();
Add Comment
Please, Sign In to add comment