PHP tutorial MySQL tutorial get the specified database tutorial all table names
If you want to show MySQL a table name for a specified database, the method is simple, MySQL provides a show tables command, it returns a data, the following is a detailed example of what I do, tested fully available
*/
$CN = mysql_connect (' localhost ', ' root ', ' root ');
mysql_select_db (' Test ', $CN);
Print_r (Get_tables ());
/* Output Results
Array
(
[0] = ABC
[1] = Cn_user
[2] = Test1
)
*/
function get_tables ()//Get all table table names
{
$tables =array ();
$r =fetch_all ("Show Tables");
foreach ($r as $v)
{
foreach ($v as $v _)
{
$tables []= $v _;
}
}
return $tables;
}
function Fetch_all ($sql)
{
$rs =mysql_query ($sql);
$result =array ();
while ($rows =mysql_fetch_array ($rs, MYSQL_ASSOC))
{
$result []= $rows;
}
return $result;
}
This site original tutorial reprint note from http://www.bKjia.c0m reserved connection address, otherwise must investigate!
?>
http://www.bkjia.com/PHPjc/630783.html www.bkjia.com true http://www.bkjia.com/PHPjc/630783.html techarticle PHP Tutorial MySQL tutorial get the specified database tutorial all table names if you want to show MySQL a table name for a specified database, the method is simple, MySQL provides a show tables command, it returns ...