Jump to content

[SOLVED] SHOW TABLES Help


Canman2005

Recommended Posts

Hi all

 

I have the following

 

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

while ($row = mysql_fetch_row($result)) {
    echo "Table: {$row[0]}\n<br>";
}
?>

 

Which outputs

 

Table: admins
Table: users
Table: people

 

This is great, but I wonder if it's possible to do these 2 things;

 

1: Rather than displaying the table name such as "admins", it would display the "table comments", so it would look like

 

Table: Table of administrators
Table: Table of site users
Table: Table of people

 

2: Is it possible to tell it to exclude specified tables, such as not displaying the "admins" table? So if I excluded the "admins" table it would finally look like

 

Table: Table of site users
Table: Table of people

 

Any help would be great, been searching Google for ages now with no luck

 

Thanks in advance

 

Dave

Link to comment
https://forums.phpfreaks.com/topic/178807-solved-show-tables-help/
Share on other sites

$ignoreList = array('admins');

$query = "SHOW TABLE STATUS";
$result = mysql_query($query);

while($record = mysql_fetch_assoc($result)
{
    if(!in_array($record['Name'], $ignoreList))
    {
        echo "Table: {$record['Comment']}<br />\n";
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.