Jump to content

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";
    }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.