Solved

MySQL SELECT COMMENT data in Statement

Posted on 2009-05-11
1
1,125 Views
Last Modified: 2012-05-06
I am dumping some MySQL data and I have used the COMMENT box in phpMyAdmin to give it a nice name. eg. `contact_forname` => 'Contact Forname' and `contact_address_1` => 'Address 1'.

How can I include this data when doing a select??

I am typically doing SELECT * FROM members and the the PHP below.
echo '<table>';
echo '<thead>';
    echo '<tr>';
    foreach($row as $key => $value){
        echo '<th>' . $key . '</th>';  // I WANT THIS TO BE THE CONTENTS OF THE COMMENT BOX!!!
    }
    echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach($result as $row) {
    echo '<tr>';
    foreach($row as $value){
        echo '<td>' .$value . '</td>';
    }
    echo '</tr>';
}
echo '</tbody>';
echo '</table>';

Open in new window

0
Comment
Question by:stmayes
1 Comment
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24354750
You can't select this directly from the table. The comment is meta data, it is not part of the table. There are however two ways you can use to find it:

You can read it from the information_schema database:

select COLUMN_NAME,COLUMN_COMMENT from information_schema.COLUMNS
where TABLE_SCHEMA='YourDatabase' and TABLE_NAME='members';

Alternatively you can do:

SHOW CREATE TABLE members;

Then you must parse the output you get, and fetch the comments.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question