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? Quote Link to comment 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>'; ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 17, 2008 Share Posted February 17, 2008 Alternatively there is also mysql_list_tables(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.