Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbname = 'shop';
- $dbuser = 'john';
- $dbpass = 'john_password';
- $dbhost = db_server;
- $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SHOW TABLES FROM $dbname";
- $result = $conn->query($sql);
- $tblCnt = 0;
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $tblCnt++;
- echo $row[0]."<br \>\n";
- }
- }
- if (!$tblCnt) {
- echo "There are no tables<br \>\n";
- } else {
- echo "There are $tblCnt tables<br \>\n";
- }
- $conn->close();
Add Comment
Please, Sign In to add comment