Home > Article > Backend Development > mysql tutorial: Reading data table field names mysql_fetch_field()_PHP tutorial
Now let’s take a look at the mysql_fetch_field() function. This function reads the example name and field name of the mysql data table. Let’s take a look at its syntax.
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 . "
";
}
The output result is all the field names of your data table.