PHP Tutorial Listing Two methods of all tables in the MySQL database tutorial
The PHP code is as follows:
function List_tables ($database)
{
$rs = MySQL Tutorial _list_tables ($database);
$tables = Array ();
while ($row = Mysql_fetch_row ($rs)) {
$tables [] = $row [0];
}
Mysql_free_result ($RS);
return $tables;
}
However, because the Mysql_list_tables method is obsolete, running the above program gives you a method-outdated hint, as follows:
Deprecated:function mysql_list_tables () is deprecated in ... on line xxx
One way to do this is to set up error_reporting in php.ini, without displaying method-outdated prompts
1 error_reporting = e_all & ~e_notice & ~e_deprecated
Another approach is to use the alternative PHP official recommendation:
function List_tables ($database)
{
$rs = mysql_query ("Show tables from $data Base ");
$tables = Array ();
while ($row = Mysql_fetch_row ($rs)) {
$tables [] = $row [0];
}
mysql_free_result ($RS);
return $tables;