...

View Full Version : Resolved Getting all tables in a database



scoop_987
08-03-2008, 09:30 PM
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.



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.

CFMaBiSmAd
08-03-2008, 09:40 PM
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.

scoop_987
08-17-2008, 06:48 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum