Code to list the tables from a mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leebies
Forum Newbie
Posts: 9
Joined: Wed Apr 23, 2003 3:18 am

Code to list the tables from a mysql database

Post 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?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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...
Post Reply