PHP functions for working with MySQL tables include:
Mysql_list_tables() takes a database name and returns a result pointer containing the tables available from the current database. The database is one parameter, and the specified link identifier ($link in our examples) is an optional second parameter.
<?php
$link = @mysql_connect("mysql_host", "userid", "userpassword")
or die("Could not connect");
$db = @mysql_select_db("database_name",$link) or
die("Could not select database");
$tbl_list = @mysql_list_tables("database_name",$link) or
die("Could not retrieve table list");
$numrows = @mysql_num_rows($tbl_list);
for ($i=0; $i<$numrows; $i++) {
echo mysql_tablename($tbl_list, $i) . "<br>";
}
?>
Similarly to mysql_db_name(), mysql_tablename() takes as its first parameter the result pointer from a call to mysql_list_tables() ($tbl_list in the example above). The second parameter is an index into the result set. If an error occurs, FALSE is returned. This function is always used in conjunction with mysql_list_tables.