Listing all Tables in a MySQL Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Listing all Tables in a MySQL Database

Post by Gen-ik »

I've searched high and low for a way to do this but haven't found a clear example yet.

Could someone please let me know how I can read and list all of the Tables in a Database.. not the Table contents.. the actual Tables?

This would be a big help. Thanks.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Don't worry I've got it...

Code: Select all

<?php
$result=mysql_query("SHOW TABLES");

while($table=mysql_fetch_array($result))
{
echo("Table : ".$table[0]."<br>\n");
}
?>
Post Reply