...

View Full Version : problem with show tables



mrjameer
08-14-2007, 02:59 PM
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

$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>";

}

?>

ThinkMedical
08-14-2007, 03:49 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum