Results 1 to 3 of 3

Thread: Retrieve mysql table names?

  1. #1
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default Retrieve mysql table names?

    hey guys!

    is it possible to retrieve the names of all tables on a mysql database with some php?

    i recently ran into a problem where i cant access my hosts control panel, therefor i cant access my mysql database as u need to access it from the control panel!

    i have been working hard on a mysql management system which is coming along very well, and pretty proud of it too!

    but.... i cant remember all of my table names, only a few.

    i would be extremely grateful if someone could help me achieve this!

    thanx
    Last edited by liamallan; 07-27-2010 at 02:00 PM.

  2. #2
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    no worries guys, i finally worked it out!

    here is how i done it incase anyone else has the same question:
    PHP Code:
    <?php
    mysql_connect
    ("localhost""username""password");
    $result mysql_list_tables("database");
    $num_rows mysql_num_rows($result);
    for (
    $i 0$i $num_rows$i++) {
        echo 
    "Table: "mysql_tablename($result$i), "\n";
    }

    mysql_free_result($result);
    ?>

  3. #3
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Try this function - mysql_list_tables() - how to use is at http://php.net/manual/en/function.mysql-list-tables.php

Bookmarks

Posting Permissions

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