Heim  >  Artikel  >  Backend-Entwicklung  >  用PHP怎么取出MYSQL中的字段的comment内容

用PHP怎么取出MYSQL中的字段的comment内容

WBOY
WBOYOriginal
2016-06-13 13:49:291197Durchsuche

用PHP如何取出MYSQL中的字段的comment内容
用PHP如何取出MYSQL中的字段的comment内容,如下面的语句建的表,如何使用PHP中的MYSQL函数取出每个字段的comment内容?

CREATE TABLE IF NOT EXISTS `zy_article` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`user_name` varchar(20) DEFAULT NULL COMMENT '用户名',
`article_type` int(11) DEFAULT NULL COMMENT '所属类别',
`article_title` varchar(255) DEFAULT NULL COMMENT '文章标题',
`article_content` text NOT NULL COMMENT '文章内容',
`post_date` datetime DEFAULT NULL COMMENT '发布时间',
`click_num` int(11) NOT NULL DEFAULT '0' COMMENT '点击次数',
`comment_num` int(11) NOT NULL DEFAULT '0' COMMENT '评论次数',
`article_tags` text COMMENT '文章标签',
`author` varchar(100) DEFAULT NULL COMMENT '作者',
`derivation` varchar(255) DEFAULT NULL COMMENT '出处',
`iscommend` char(1) NOT NULL DEFAULT '0' COMMENT '是否推荐',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=80 ;

------解决方案--------------------
使用Show命令
SHOW TABLE STATUS; or
mysqlshow --status TABLE;
------解决方案--------------------
错了,应该用
show full fields from '表名称'

------解决方案--------------------

PHP code
function show_fields($sql)
    {
        $result=mysql_query($sql);
        $data=array();
        while ($row=mysql_fetch_array($result))
        {
            $data[]=$row['Field'];
        }
        return $data;
    }
<br><font color="#e78608">------解决方案--------------------</font><br>调用:<br>print_r(show_fields('show full fields from zy_article')); <div class="clear">
                 
              
              
        
            </div>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn