简体   繁体   中英

php how to create a dropdown select input of all table from a database?

for example, I have a database named "school", and it contains 3 tables "teacher", "student" and "staff". I wanna create one form with one select input with option of all 3 tables, and you can choose any of these 3 tables to insert data into.

thank you.

To get all table name from database try this:

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='dbName'

Note: Use select2 library or other library for multi-pick list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM