Php searches for all the table names in the mysql database. To display the names of all tables in a specified database in mysql, we can use the SHOWTABLES command. let's take a look at how SHOWTABLES obtains the names of all tables in the mysql database. To display the names of all TABLES in a specified database in mysql, we can use the show tables command. let's take a look at how show tables obtains the names of all TABLES in the mysql database.
Run the command in cmd mode.
The code is as follows: |
|
Show databases; Show tables from db_name;
Show columns from table_name from db_name; Show index from talbe_name [from db_name]; Show status; Show variables; Show [full] processlist; Show table status [from db_name]; Show grants for user; |
Combined with the php mysql database
The code is as follows: |
|
$ Server = 'localhost '; $ User = 'root '; $ Pass = ''; $ Dbname = 'dayanmei _ com '; $ Conn = mysql_connect ($ server, $ user, $ pass ); If (! $ Conn) die ("database system connection failed! "); Mysql_select_db ($ dbname) or die ("database connection failed! "); $ Result = mysql_query ("show tables "); While ($ row = mysql_fetch_array ($ result )) { Echo $ row [0]. ""; Mysql_free_result ($ result ); } |
Note that the mysql_list_tables function for listing all table names in mysql in php has been deleted. we recommend that you do not use this function list for mysql data tables.
TABLES can be implemented. let's take a look at how show tables obtains all the table names in the mysql database ....