If you want to display MySQL a specified database table name the method is very simple, MySQL provides a show tables command, it returns a data, the following I do a detailed example, tested fully available
*/
The code is as follows |
Copy Code |
$CN = Mysql_ Connect (' localhost ', ' root ', ' root '); mysql_select_db (' Test ', $CN); Print_r (Get_tables ()); /* Output results Array ( [0] => ABC [1] => cn_user [2] =& Gt 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; } &NBSP return $result; } |
//Site Original tutorial reproduced annotated from http://www.111cn.net reserved connection address, otherwise will be!
?>