Question : Show database tables and columns in php

I need to be able to show the database tables and fields form a mysql db. (I do not require values)

e.g

 - Table 1
    -- Field 1
    -- Field 2
    -- Field 3

 - Table 2
    -- Field 1
    -- Field 2
    -- Field 3

 - Table 3
    -- Field 1
    -- Field 2
    -- Field 3

and so on.

I am currently only getting just tables, and need to combine fields also.
1:
2:
3:
4:
5:
6:
7:
$tables = mysql_list_tables("database");
   $count = 0;

   while ($count < mysql_numrows($tables)) {
      echo mysql_tablename($tables,$count)."<br />";
      $count++;
   }

Answer : Show database tables and columns in php

try this - I tested it on one of my dev servers and it does what you want (adding some error checking would be good)
1:
2:
3:
4:
5:
6:
7:
8:
$vQuery = mysql_query('SHOW TABLES');
while($vTable = mysql_fetch_array($vQuery)){
  print 'Table: '.$vTable[0].'<br />';
  $vQuery2 = mysql_query('SHOW COLUMNS FROM '.$vTable[0]);
  while($vField = mysql_fetch_array($vQuery2)){
    print ' - '.$vField[0].'<br />';
  }
}
Random Solutions  
 
programming4us programming4us