ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello; I have a LAMP server and I'm trying to write a PHP script to help keep track of some information on a database. I want the web interface to present to the user the option of what table to draw queries from. The database will be constant, but the table will be chosen by the user. For example, if we're using database "languages" and tables "c++", "lisp", and "ruby" exist in it, I want to be able to tell the user that they can choose from either "c++", "lisp", or "ruby". In other words, I need to discover from the database what tables exist inside it. Is there a way to do this with a PHP function or a MySQL command? Thanks.
You cannot use "Select" to get table names. But on the other hand, "SHOW TABLES" is a (limited) query in MySQL. And you can use "FROM database_name" and "LIKE 'col%'" with "SHOW TABLES".
It looks like "SELECT Table_Name FROM User_Tables" may get the metadata regarding what tables are present directly from the database. Since this is part of the idea behind Relational Databases (that they self-contain their metadata in the same manner that they would any other data), that would make perfect sense. I wonder if you couldn't do the same thing in MySQL, assuming you knew what hidden system-table stored metadata about the rest of the tables in that particular database.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.