Jump to content

[SOLVED] Listing Table Names.. Please Help


eugene2009

Recommended Posts

Hey, is it possible to list all the table names in a database on an html page?

 

For example:

 

Database Name: Cars

 

Table Names:

 

-BMW

-Mercedes

-Volkswagen

-Ford

-Volvo

 

How do I have it generate that list automatically if I add new tables later on?

Link to comment
https://forums.phpfreaks.com/topic/179368-solved-listing-table-names-please-help/
Share on other sites

is it possible to show tables from 2 databases in one list..

 

how would i make this work????

 

mysql_select_db ([color=red][b]test, blog[/b][/color]);

$result = mysql_query("SHOW TABLES");

echo '<ul>';
while($row = mysql_fetch_array($result)) {
   echo '<li>' . $row[0] . '</li>';
}
echo '</ul>';

 

sorrryy exclude the font formatting..

 

 

mysql_select_db (test, blog);

$result = mysql_query("SHOW TABLES");

echo '<ul>';
while($row = mysql_fetch_array($result)) {
   echo '<li>' . $row[0] . '</li>';
}
echo '</ul>';

I don't believe you can select multiple tables like that, but you should be able to do this...

 

echo '<ul>';
$result = mysql_query("SHOW TABLES FROM table1");
while($row = mysql_fetch_array($result)) {
   echo '<li>' . $row[0] . '</li>';
}
$result = mysql_query("SHOW TABLES FROM table2");
while($row = mysql_fetch_array($result)) {
   echo '<li>' . $row[0] . '</li>';
}
echo '</ul>';

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.