Try the code below, it will give you a listing of the databases and the tables in each. I also have a file to display the fields and some information on them, along with letting you insert/update/delete data once you select a table from this page.
Read the notes for more information on how to connect to the db initially.
questions? try me @ irishprogramming@hotmail.com
<?
global $link;
$link = mysql_connect("localhost", "root", "ROOTPASSWORD") or die("Could not connect Error: " . mysql_error());
?>
<?
/*
Purpose: Create a listing of all the databases,
and the tables within each database
Author: Patrick Hartnett
Date: 05-13-2002
Note: You will need to connect (above) as the 'root' user who has unrestricted access to mysql
Variable Listing:
$rsDBList - recordset containing the databases available
$nCnt - the number of rows in $rsDBList
$nCounter - a simple counter to cycle through $rsDBList
$DatabaseName - the current database name
$rsTableList - recordset containing the current database's tables
$nPointer - a simple counter to cycle through $rsTableList
$TableName - the current table name
/
print "<HTML>";
print "<BODY>";
/ Get the list of databases /
$rsDBList = mysql_list_dbs($link);
print "<TABLE width=100% border=0>\n";
print "<CAPTION align=left>\n";
print "<STRONG>Available Tables</STRONG>\n";
print "</CAPTION>\n";
$nCounter = 0;
$nCnt = mysql_num_rows($rsDBList);
/ cycle through the list of tables to build the menu hierarchy/
while ($nCounter < $nCnt)
{
print "<TR>\n";
/ print the DatabaseName column /
print "<TD>\n";
$DatabaseName = mysql_db_name($rsDBList, $nCounter);
echo $DatabaseName . "\n";
print "</TD>\n";
/ Get the list of tables /
$rsTableList = mysql_list_tables($DatabaseName);
for ($nPointer = 0; $nPointer < mysql_num_rows($rsTableList); $nPointer++)
{
print "<TR>\n";
/ print a spacer column /
print "<TD width=3%>";
print " ";
print "</TD>";
/ print the table name column /
print "<TD width=75%>\n";
/ Set the variables to pass to the next page, and encode them /
$TableName = mysql_tablename($rsTableList, $nPointer);
$DatabaseName=urlencode($DatabaseName);
$TableName=urlencode($TableName);
/ create the link to view this table /
echo ("<A HREF='fieldlist.php?databasename=$DatabaseName&tablename=$TableName'>" . $TableName . "</A><br />");
print "</TD>\n";
print "</TR>\n";
}
print "</TR>\n";
/ get the next database /
$nCounter++;
}
print "</table>\n";
print "</body>";
print "</html>";
/Close out the result sets/
mysql_free_result($rsTableList);
/ Closing connection to mysql*/
mysql_close($link);
?>