How to loop through a list of tables from a database?

Hello everyone.

There is a database with tables and a connection to it. The name and number of tables is not known in advance. Is there a way to loop through a list of tables from a mysql database?


Answer 1, authority 100%

$result = mysql_list_tables($dbname); 
 while ($row = mysql_fetch_row($result)) 
       echo $row[0]."<br>";

Well, there are standard functions, why doesn’t anyone read manuals?


Answer 2

$sql_query=$mysqli->query("SHOW TABLES FROM `MySqlDB` LIKE '%';");
while ($row=$sql_query->fetch_array()){
    echo "$row[0]</br>";
}

DB and LIKE pattern substitute your own.fetch you can take any: row, array, assoc