PHP MySQL Functions to list table names in a databasesWe can list tables present in a database by using this query
Using this we can develop a PHP script to display all tables.
Show tables of a databaseWe can display tables of a database by changing the above query.
Above query will return all the tables of the database pdoSimilarly if we want to list all the tables starting with char t then we can use LIKE command. Here is the query.
Above query can be placed inside the PHP code (shown above ) to display matching tables. For easy understanding here again the php code.
Using MySQLI
This old MySQL extension was deprecated in PHP 4.3.0 and was removed in PHP 7
Use SHOW TABLE query in place of mysql_list_tables(). mysql_list_tables()We can display a list of tables present in a database by using mysql_list_tables() function. Connection has to be established before call of this function. The result pointer returned by this function is used by mysql_tablename() function to display the name of the tables.
This article is written by plus2net.com team.
![]() ![]() | ||||||||||||
| ||||||||||||