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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with show tables

    hi,



    when i use the following code to display tables in a database 2 formats are working and 2 are not working.please check where iam wrong

    thanks
    mrjameer
    PHP Code:
    <?php

    $mysqli
    =new mysqli("localhost","root","root","upper");

    $query="SHOW TABLES";

    $result=$mysqli->query($query) or die ($mysqli->error);

    //1.this is working
    while($row=$result->fetch_array())
    {
        echo 
    $row[0];
        echo 
    "<br>"

    }
    //2.this is also working
    while($row=$result->fetch_row())
    {
        echo 
    $row[0];
        echo 
    "<br>"

    }
    //3.it's not working
    while($row=$result->fetch_assoc(MYSQLI_ASSOC))
    {
        echo 
    $row[0];
        echo 
    "<br>"

    }

    //4.not working
    while($row=$result->fetch_object())
    {
        echo 
    $row->Tables;
        echo 
    "<br>"

    }

    ?>

  • #2
    New Coder
    Join Date
    Jul 2007
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    fetch_assoc will give you an ASSOCIATIVE array... i.e. string keys, so $row[0] will not work, they key will be something like Tables_in_upper , you will need to print_r/var_dump $row to find out the key exactly. same problem for the object "Tables" isnt the col. name.


  •  

    Posting Permissions

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