随笔 - 78  文章 - 25  trackbacks - 0
<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿

随笔分类(75)

随笔档案(78)

相册

实用Links

我的Links

搜索

  •  

积分与排名

  • 积分 - 112098
  • 排名 - 521

最新评论

阅读排行榜

评论排行榜

获取字段信息
mysql_fetch_field()
mysql_num_fields()
mysql_list_fields()
mysql_field_flags()
mysql_field_len()
mysql_field_name()
mysql_field_type()
mysql_field_table()
注意:字段的属性有:name ,table,max_length,not_null,primary_key,
unique_key,multiple_key,numeric,blob,type,unsigned,zerofill

示例:
<?php
    $link=mysql_connect("localhost","root","root") or die("couldn't connect:".mysql_error());
    mysql_select_db("rorely");
    $result=mysql_query("select * from test")or die("query failed:".mysql_error());
    for($i=0;$i<mysql_num_fields($result);$i++){
        $meta=mysql_fetch_field($result);
        if(!$meta) echo "没有字段信息.<br>";
        echo "<pre>".$meta->name."<br>".$meta->type."<br>".$meta->max_length."<hr></pre>";
    }
    mysql_free_result($result);
    
?>

结果如下:
id
int
2
name
string
4
age
int
2
sex
string
6
address
string
16

posted on 2009-07-02 14:33 期待明天 阅读(715) 评论(0)  编辑  收藏 所属分类: PHP

只有注册用户登录后才能发表评论。


网站导航: