MySQL databases store data in tables.
For storage of data in the database, it is necessary that it contains at least one created MySQL table.

Show list of tables on MySql database

To show the list of tables in a MySQL database, you can use the following SQL query: SHOW TABLES FROM $dbname;

This function retrieves a list of table names from a MySQL database. The SQL query to get all table names in the current database is: SHOW TABLES;

Full code to show list of tables on MySql database

$dbuser "yourusername"
$dbpass "yourpassword"
$dbname "yourdatabase";
$conn = new mysqli($dbhost$dbuser$dbpass$dbname);

// Check connection
if ($conn->connect_error) {
"Connection failed: " $conn->connect_error);

$result $conn->query($sql);

if (
$result->num_rows 0) {
// Output the names of the tables
echo "List of tables in the database:<br>";
$row $result->fetch_array()) {
$row[0] . "<br>";
} else {
"No tables found in the database.";


Privacy Policy