What database are you using that you want to list the tables from?
Here is some code that does it for:
MySQL: This code uses a class I've written to make the connection to the database, but that can be easily removed and replaced with a standard mysql_connect call.
////
// getTables: will return a listing of all tables in the passed database.
// needs the database name, and an array to populate.
// returns a count of all tables found
////
function getTables($database, &$data) {
global $dbUser, $dbPawwsord, $dbHost;
$intDB = new DBConnection($database, $dbUser, $dbPassword, $dbHost);
$tables = mysql_list_tables($database, $intDB->dbConn);
for ($i = 0; $i < mysql_num_rows($tables); $i++) {
$data[$i+1]["TABLENAME"] = mysql_tablename($tables, $i);
}
$row_id = $i+1;
$intDB->Destroy();
return $row_id;
}
PostgreSQL: This class also uses a database connection class.
////
// getTables: will return a listing of all tables in the passed database.
// needs the database name, and an array to populate.
// returns a count of all tables found
////
function getTables($database, &$data) {
global $dbHost, $dbPort, $dbOptions, $dbTTY;
$intDB = new DBConnection($database,$dbHost,$dbPort,$dbOptions,$dbTTY);
$query = "SELECT tablename
FROM pg_tables
WHERE tablename !~ 'pg_'";
$tables = array();
$tbl_count = $intDB->doSelect($query, $tables);
$start = count($data);
for ($i = 1; $i <= $tbl_count; $i++) {
$row_id = $start + $i;
$data[$row_id] = $tables[$i];
}
$intDB->Destroy();
return $row_id;
}