Page 1 of 1

Code to list the tables from a mysql database

Posted: Fri Nov 25, 2005 3:10 pm
by leebies
Newbie here. My site is http://www.makeadifference.in. I currently have html list on the front page of counties that link to pages that call the information from the database.

I have created the connection to the database with a config.php file:
<?php
$dbhost = 'myserver';
$dbuser = 'myuser';
$dbpass = 'mypassword';
$dbname = 'mydbname';
?>
I now want to display the list of counties (which are the table names in the mysql database) so they output in list format with links also:
Example: <a href="$tablename">$tablename</a>
Can someone help?

Posted: Fri Nov 25, 2005 3:19 pm
by Burrito
for starters, I think you should consider restructuring your database and listing your countires as rows in a separate table

to answer your question though you can use "show tables;" as a query to list your tables...