(8) Take the database name and table name (2):
1, Mysql_list_dbs ()
Format: int Mysql_list_dbs (int link_identifier);
Gets all available database names (db name).
Example:
<?php
$connect = mysql_connect ($host, $USR, $pwd);
$dbs = Mysql_list_dbs ($connect);
$rows = mysql_num_rows ($dbs);
echo "Database total:". $rows;
$i = 0;
while ($i < $rows)
{
$db _name[$i] = Mysql_tablename ($dbs, $i);
echo $db _name[$i];
$i + +;
}
?>
You can display all of the database names in MySQL, in turn.
Note: Equivalent to the show databases command in MySQL
2, Mysql_list_tables ()
Format: int mysql_list_tables (string database name);
Displays the names of all tables under the database, table name.
Example:
<?php
$connect = mysql_connect ($host, $USR, $pwd);
$tables = Mysql_list_tables ("MySQL");
$rows = mysql_num_rows ($tables);
echo "Table total:". $rows;
$i = 0;
while ($i < $rows)
{
$table _name[$i] = Mysql_tablename ($tables, $i);
echo $table _name[$i];
$i + +;
}
?>
You can display the names of all the tables under MySQL in turn
Note: Equivalent to the show Tables command in MySQL (use MySQL command to select 1 databases first)