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 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts

    Getting all tables in a database

    Right, this is quite complicated. Im wanting to get the names of all the tables in a database. BUT, the code ive got is only showing one out of 10 for some unknown reason. Its basically to make sure theres nothing wrong with the tables in the database.

    PHP Code:
        include("config.php");
        
    //We NEED to check that all the tables we use exist (if any mod is applied, you may add your table(s) here):
        
    $TABLES = array("bbcode",
                        
    "blocked_users",
                        
    "configuration",
                        
    "images",
                        
    "invites",
                        
    "private_messages",
                        
    "rooms",
                        
    "shouts",
                        
    "smilies",
                        
    "users");
        
        
    $Q mysql_query("SHOW TABLES;");
        
    $DATA mysql_fetch_assoc($Q);
        echo(
    $DATA['Tables_in_test2']); 
    can someone tell me where im going wrong? the array is the names of mandatory tables.
    Last edited by Inigoesdr; 08-18-2008 at 12:33 AM.
    Current Project: Nothing at the minute

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,107
    Thanks
    2
    Thanked 326 Times in 318 Posts
    The definition of mysql_fetch_assoc (and for all the mysql_fetch_xxxxx functions) -

    Fetch a result row as an associative array

    Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
    Each call returns one row from the result set.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    scoop_987 (08-17-2008)

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    well... is there any other way of getting data from a query without using a fetch_xxxxx as array, assoc, row, field are all giving only one table when i need all 10 or however many there is.

    EDIT:
    Fixed it, wasnt thinking straight, Needed to add a while loop in.
    Last edited by scoop_987; 08-17-2008 at 05:52 PM.
    Current Project: Nothing at the minute


  •  

    Posting Permissions

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