...

View Full Version : Resolved Using PHP to show MySQL Tables



[vengeance]
01-15-2010, 11:14 PM
Hi.

Using show tables in phpMyAdmin will display all of my tables. Is this possible to achieve through PHP and echo out the tables on my webpage?

oracleguy
01-15-2010, 11:18 PM
Yes. Just run show tables as the SQL query on your PHP page and the recordset returned will be the table list. See also: http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

[vengeance]
01-15-2010, 11:22 PM
Well, I'm kinda stuck on ..



$query = mysql_query("SHOW TABLES") or die(mysql_error());


How would I actually display the full list now?

oracleguy
01-15-2010, 11:27 PM
Just like any other query:



while($row = mysql_fetch_array($query))
{
echo $row[0]
}


Are you just wanting the names or do you want the columns and data types in each table too?

[vengeance]
01-15-2010, 11:30 PM
Just like any other query:



while($row = mysql_fetch_array($query))
{
echo $row[0]
}


Are you just wanting the names or do you want the columns and data types in each table too?
Thanks. Yeah, next step is to grab the columns and data within the desired table, if you don't mind. :)

oracleguy
01-15-2010, 11:36 PM
To get the table information, you use the describe query. See this page for usage and what columns it returns: http://dev.mysql.com/doc/refman/5.0/en/describe.html

[vengeance]
01-15-2010, 11:40 PM
To get the table information, you use the describe query. See this page for usage and what columns it returns: http://dev.mysql.com/doc/refman/5.0/en/describe.html

Thanks for your help!
Problems solved.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum