Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    Using PHP to show MySQL Tables

    Hi.

    Using show tables in phpMyAdmin will display all of my tables. Is this possible to achieve through PHP and echo out the tables on my webpage?
    Last edited by [vengeance]; 01-15-2010 at 11:40 PM.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Yes. Just run show tables as the SQL query on your PHP page and the recordset returned will be the table list. See also: http://dev.mysql.com/doc/refman/5.0/en/show-tables.html
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Well, I'm kinda stuck on ..

    Code:
    $query = mysql_query("SHOW TABLES") or die(mysql_error());
    How would I actually display the full list now?

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Just like any other query:

    PHP Code:
    while($row mysql_fetch_array($query))
    {
    echo 
    $row[0]

    Are you just wanting the names or do you want the columns and data types in each table too?
    OracleGuy

  • #5
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by oracleguy View Post
    Just like any other query:

    PHP Code:
    while($row mysql_fetch_array($query))
    {
    echo 
    $row[0]

    Are you just wanting the names or do you want the columns and data types in each table too?
    Thanks. Yeah, next step is to grab the columns and data within the desired table, if you don't mind.

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    To get the table information, you use the describe query. See this page for usage and what columns it returns: http://dev.mysql.com/doc/refman/5.0/en/describe.html
    OracleGuy

  • Users who have thanked oracleguy for this post:

    [vengeance] (01-15-2010)

  • #7
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by oracleguy View Post
    To get the table information, you use the describe query. See this page for usage and what columns it returns: http://dev.mysql.com/doc/refman/5.0/en/describe.html
    Thanks for your help!
    Problems solved.


  •  

    Posting Permissions

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