Skip to main content

How to get table count for all tables in a database in Mysql?

By November 9, 2011My SQL
Following Example shows you how to get tables list from database using PHP CODE.
$dbname = 'mysql_dbname';

if (!mysql_connect('localhost', 'root', '')) {
    echo 'Could not connect to mysql';
$sql = "SHOW TABLES FROM $dbname";$result = mysql_query($sql);

if (!$result) {
    echo "DB Error, could not list tablesn";
    echo 'MySQL Error: ' . mysql_error();

while ($row = mysql_fetch_row($result)) {
    echo "Table: $row[0] n";

Leave a Reply

+ 30 = 34

Open chat
💬 Need help?
Hello 👋
We are expert at building website and digital properties. Do you have an idea that you want to bring to life. Let us know and we will build it for you.