Perad Posted February 17, 2008 Share Posted February 17, 2008 How can I list the tables in a database and store them in a $key -> tablename array? Link to comment https://forums.phpfreaks.com/topic/91506-list-tables-in-a-database/ Share on other sites More sharing options...
Barand Posted February 17, 2008 Share Posted February 17, 2008 try <?php $cnx = mysql_connect('localhost', '****', '*****'); mysql_select_db('****'); $tables = array(); $res = mysql_query("SHOW TABLES"); while ($r = mysql_fetch_row($res)) { $tables[] = $r[0]; } echo '<pre>', print_r($tables, true), '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/91506-list-tables-in-a-database/#findComment-468722 Share on other sites More sharing options...
Perad Posted February 17, 2008 Author Share Posted February 17, 2008 Thanks a lot, i'll give this a go. Link to comment https://forums.phpfreaks.com/topic/91506-list-tables-in-a-database/#findComment-468724 Share on other sites More sharing options...
Daniel0 Posted February 17, 2008 Share Posted February 17, 2008 Alternatively there is also mysql_list_tables(). Link to comment https://forums.phpfreaks.com/topic/91506-list-tables-in-a-database/#findComment-468725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.