Home >php教程 >php手册 >mysql教程:读取数据表字段名 mysql_fetch_field()

mysql教程:读取数据表字段名 mysql_fetch_field()

WBOY
WBOYOriginal
2016-06-13 10:07:121697browse

现在我们来看看 mysql_fetch_field()  函数吧,这个函数 是就读取mysql 数据表的例名,字段名.下面我们来看看它的语法哦.

mysql_fetch_field(data,field_offset)
<p><strong>mysql_fetch_field()</strong> 函数对像是记录集返回.mysql_query ( )函数并返回一个对象上的成功,或FALSE或失败时</p><p> </p><p>他有两个参数.data 与 field_offset</p><p> </p><p>data:必选若,指定的数据指针使用。数据指针是由于从mysql_query ( )函数</p><p> </p><p>field_offset:可选,从哪条记录开始读取,不写是代码从0开始.</p><p> </p><p>现在我们来看一个mysql_fetch_field实例.</p><p></p><pre class="brush:php;toolbar:false">$sql = "SELECT * from a";
 
$result = mysql_query($sql,$con);

 

while ($property = mysql_fetch_field($result)) { echo "Field name: " . $property->name . "
"; }

 

输出的结果就是你数据表的所有字段名哦.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn