Is there a way to grab the columns name of a table in mysql? using php
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
The MySQL function describe table should get you where you want to go (put your table name in for "table"). You'll have to parse the output some, but it's pretty easy. As I recall, if you execute that query, the PHP query result accessing functions that would normally give you a key-value pair will have the column names as the keys. But it's been a while since I used PHP so don't hold me to that. :)
This solution is from command line mysql
In below query just change <--DATABASE_NAME--> to your database and <--TABLENAME--> to your table name where you just want Field values of DESCRIBE statement
I have write a simple php script to fetch table columns through PHP: Show_table_columns.php
Enjoy!
There's also this if you prefer:
this worked for me..
I made a PDO function which returns all the column names in an simple array.
The output will be an array:
Sorry for the necro but I like my function ;)
P.S. I have not included the class Core but you can use your own class.. D.S.