I'm selecting random fields values from a MySQL database. The fields are selected dynamically and these are different on each query. Now I want to assign the description to every field and print the field description.
For example I have selected two fields such as: web_seo
and web_maintenance
then I want to show the above fields as (Do you want your website SEO) and (Do you want your website maintenance from our company) respectively.
if its MySql
you can assign comments to the actual column within the database.
ALTER TABLE tbl CHANGE COLUMN col col INT(11) NOT NULL COMMENT 'This is the new comment';
You can then select these comments using the information_schema
(MySql 5.0+)
SELECT
comments FROM information_schema.tables
WHERE
table_schema = 'dbname'
AND
table_name = 'tbl'
Edit
Forgot to say, the information_schema
contains all the metadata for all your databases, it may be worth creating a new MySQL
user that has specific access to the schema/tables required to avoid the obvious security issues.
More information can be found here:
http://dev.mysql.com/doc/refman/5.0/en/information-schema.html