Results 1 to 2 of 2

Thread: Displaying all tables/columns

  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Question Displaying all tables/columns

    Is there any easy way besides, show tables, and then a series of show columns from, to see all the columns from all the tables in my database. My database currenlty has around 20 tables or so and I would like to print an updated list of all the columns in the tables for reference, and I am just wondering if there is any easy way to do this... Thanks!

  2. #2
    Join Date
    Dec 2003
    Posts
    2

    PHP solution

    Well once i posted it and started thinking i was sure i could do it in php. And this is what i came up with, it works nicely so if anyone needed it here is the code that i wrote for it...

    $result = mysql_list_tables($database);
    print"<table align = center border = 1>";
    while($row = mysql_fetch_array($result) )
    {
    print"<tr><th align = center>$row[0]</th></tr>";
    $fields = mysql_list_fields($database, "$row[0]");
    $columns = mysql_num_fields($fields);
    for( $i = 0; $i < $columns; $i++ )
    {
    $name = mysql_field_name($fields, $i);
    print"<tr><td align = center>$name</td></tr>";
    }
    print"<tr></tr>";
    }
    print"</table>";

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •