johnska7 Posted October 13, 2006 Share Posted October 13, 2006 Hi all,I've been trying to find an answer to this and as of yet I've had no luck. What I'm trying to do is access the comment field for a mysql column (field) so that I can use it to display information. I know it's possible, as phpmyadmin displays the comments, but I can't figure out how they do it.Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/ Share on other sites More sharing options...
HuggieBear Posted October 13, 2006 Share Posted October 13, 2006 Are comments a feature of MySQL or phpMyAdmin though?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108354 Share on other sites More sharing options...
akitchin Posted October 13, 2006 Share Posted October 13, 2006 assuming comments is a feature describing something about the column itself (like the type, special options, etc.), look in the MySQL manual for the DESCRIBE statement. Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108359 Share on other sites More sharing options...
HuggieBear Posted October 13, 2006 Share Posted October 13, 2006 DESCRIBE doesn't show it... Use SHOW with the 'FULL' keyword...Change table_name for your table[code]<?php$sql = "SHOW FULL COLUMNS FROM table_name";$result = mysql_query($sql);$row = mysql_fetch_array($result, MYSQL_ASSOC);echo $row['Comment'];?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108361 Share on other sites More sharing options...
johnska7 Posted October 13, 2006 Author Share Posted October 13, 2006 O.k., Huggie, your idea semi worked...I can see the results when I execute that line in mysql admin, but when I try to execute your code (and other iterations) in a web page, I just get a blank screen. Also, I checked to see how many rows were being returned in the fetch and only 5 were returned...I have well over 3000 rows in the database, and about 13 rows that it shows for "fields" when I execute the SHOW in mysql admin...any idea what might be going on? Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108507 Share on other sites More sharing options...
HuggieBear Posted October 13, 2006 Share Posted October 13, 2006 Ooops, I forgot the while loop...[code]<?php$sql = "SHOW FULL COLUMNS FROM table_name";$result = mysql_query($sql);while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "$row['Field'] - $row['Comment']<br>\n";}?>[/code]I also added the 'field' value so that you get the column name too.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108532 Share on other sites More sharing options...
johnska7 Posted October 13, 2006 Author Share Posted October 13, 2006 Perfect! I need to figure out how to get it to flow with what I already have, but it's great.And I figured out why it wasn't showing before...I was selecting the wrong table...TGIF :) Quote Link to comment https://forums.phpfreaks.com/topic/23851-grabbing-mysql-column-comments/#findComment-108574 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.