Jump to content

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>';

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.