473,378 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

retrieving table comment from mysql database

Hi Gurus

Is there a way to retrieve the table comment from a mysql table.

In PHP My Admin, you can set the comment for a table. however, I was
wondering if you can retrieve it for use in a PHP page.

Any help greatly appreciated.

- Nicolaas
Jul 23 '05 #1
5 1979
windandwaves wrote:
Hi Gurus

Is there a way to retrieve the table comment from a mysql table.

In PHP My Admin, you can set the comment for a table. however, I was
wondering if you can retrieve it for use in a PHP page.

Any help greatly appreciated.


Comment saved in a PHP_My_Admin table.
Jul 23 '05 #2
>Is there a way to retrieve the table comment from a mysql table.

In PHP My Admin, you can set the comment for a table. however, I was
wondering if you can retrieve it for use in a PHP page.

Any help greatly appreciated.


In PHP 5.0.x, it's in information_schema.tables.table_comment .

It's also in SHOW CREATE TABLE in PHP 5.0.x and earlier versions.

Gordon L. Burditt
Jul 23 '05 #3
NC
windandwaves wrote:

Is there a way to retrieve the table comment from
a mysql table.


Yes. Run a SHOW CREATE TABLE query on the table you want
to see the comment for. For example, if you have a table
called `example`, the query will be:

SHOW CREATE TABLE example;

It will return a CREATE TABLE statement for the table,
which will include the comment. You will need to parse
it out of the CREATE TABLE statement.

Cheers,
NC

Jul 23 '05 #4
NC wrote:
windandwaves wrote:

Is there a way to retrieve the table comment from
a mysql table.


Yes. Run a SHOW CREATE TABLE query on the table you want
to see the comment for. For example, if you have a table
called `example`, the query will be:

SHOW CREATE TABLE example;

It will return a CREATE TABLE statement for the table,
which will include the comment. You will need to parse
it out of the CREATE TABLE statement.


Thank you for clarifying this.

- Nicolaas
Jul 23 '05 #5
windandwaves wrote:
Hi Gurus

Is there a way to retrieve the table comment from a mysql table.

In PHP My Admin, you can set the comment for a table. however, I was
wondering if you can retrieve it for use in a PHP page.

Any help greatly appreciated.

- Nicolaas


This is the function I made up (I only use one space as indent):

function table_description($t) {
$sql = 'SHOW CREATE TABLE `'.$t.'`;';
$query = mysql_query($sql);
$v = mysql_result($query, 0, 1);
if($v) {
$p = strpos($v,"COMMENT=");
if($p) {
return substr($v, $p + 8);
}
}
return 'Table description not found';
}
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Josep | last post by:
Hi, I'd like to poll a database and get the table contents, as well as the field names from that table. I've been to php.net but this time I cannot find something helpful. I can get the data,...
3
by: Bert Sierra | last post by:
Hello -- I have what appears to be a simple PHP+MySQL query, but Dreamweaver consistently generates PHP code which won't parse. I've stared at the PHP code for several hours now, and I can't...
3
by: Oliver Kohll | last post by:
Hi, I can't seem to retrieve a comment on a table column. The following copy from psql should I think return a comment: ==================== mydatabase=> COMMENT ON COLUMN car.manufacturer IS...
10
by: Krakatioison | last post by:
Hi everyone, can someone point me to download of an example for saving and retrieving to/from MYSQL database. Or did anyone of you tried this and could share your code with me. I've got some data...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
3
by: wongwaichi | last post by:
Hi, everyone. I am not sure if i am writing in the correct group. But somehow it relates to MySQL, i hope someone can help me. I am working on a web site which is developed by PHP and MySQL,...
2
by: gophersounds | last post by:
When I run this simple program I am not getting any data back. The program creates a database, creates a table, populates the table with some data, and then tries to read the data. However, no...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
1
oranoos3000
by: oranoos3000 | last post by:
hi i have an error with enter record to table in database(mysql) structure of my table is as follow - phpMyAdmin SQL Dump -- version 2.11.6 -- http://www.phpmyadmin.net -- -- Host:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.