This code shows all column names from a specific table, the schema INFORMATION_SCHEMA stores information about the items created on your database server(schemas, tables, columns etc.)
The statement above will show you alle columns from tablename
, theres also a more simple syntax to do this SHOW COLUMNS FROM tablename
(MySQL Manual)
How do you want to determine that the value of a column is true? Maybe there a two rows in your table with the values TRUE and FALSE for one column (TRUE in one row and FALSE in the other row)
With one Row in PHP
If there is only one row in your table execute the SHOW COLUMNS FROM tablename
do a fetch_array
on the result and then foreach and save only the keys where the value is TRUE.
If you try to store something like a configuration use a key value table and query it using where clause, this will be more effective.