eugene2009 Posted October 28, 2009 Share Posted October 28, 2009 Hey, is it possible to list all the table names in a database on an html page? For example: Database Name: Cars Table Names: -BMW -Mercedes -Volkswagen -Ford -Volvo How do I have it generate that list automatically if I add new tables later on? Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/ Share on other sites More sharing options...
tommyda Posted October 28, 2009 Share Posted October 28, 2009 Youd be better off creating a table called cars and adding fields (carname) Then you can select * from cars and echo the names in a while loop Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-946435 Share on other sites More sharing options...
eugene2009 Posted October 28, 2009 Author Share Posted October 28, 2009 yea i know that.. im just wondering if thats possible.. Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-946444 Share on other sites More sharing options...
fenway Posted October 31, 2009 Share Posted October 31, 2009 If what's possible? Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-948410 Share on other sites More sharing options...
DavidAM Posted October 31, 2009 Share Posted October 31, 2009 SHOW TABLES will return a list of all tables in the database. At least the tables that you have priviledges to see. It returns a resultset just like any other query. Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-948439 Share on other sites More sharing options...
Mchl Posted October 31, 2009 Share Posted October 31, 2009 So now that DavidAM gave you the solution, I give you the reading: http://datacharmer.blogspot.com/2009/03/normalization-and-smoking.html Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-948450 Share on other sites More sharing options...
DavidAM Posted November 1, 2009 Share Posted November 1, 2009 For example: Database Name: Cars Table Names: -BMW -Mercedes -Volkswagen -Ford -Volvo In my post to provide the answer, I neglected to say: "This does NOT look like a good design." However, without knowing why it was designed that way, or if, in fact, this was just an example pulled from the air, to explain the question, I did not condemn it immediately. @eugene2009 If this is the design of your database, you may need to re-think it. If you'd like us to review the design and provide insight, you may want to start a new topic. If you are working on an admin-type page to let you review databases, tables, and data (as I have done on occasion), you might want to look at the SHOW and DESCRIBE commands of mySql. They can provide much information about the database and it's contents. Good Luck! Quote Link to comment https://forums.phpfreaks.com/topic/179369-listing-table-names-please-help/#findComment-948757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.