现在我们来看看 mysql_fetch_field() 函数吧,这个函数 是就读取mysql 数据表的例名,字段名.下面我们来看看它的语法哦.
mysql_fetch_field(data,field_offset)
<p><strong>mysql_fetch_field()</strong> 函数对像是记录集返回.mysql_query ( )函数并返回一个对象上的成功,或FALSE或失败时</p><p> </p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p><p>他有两个参数.data 与 field_offset</p><p> </p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p><p>data:必选若,指定的数据指针使用。数据指针是由于从mysql_query ( )函数</p><p> </p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p><p>field_offset:可选,从哪条记录开始读取,不写是代码从0开始.</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/732">
<img src="https://img.php.cn/upload/ai_manual/000/000/000/175679952967256.jpg" alt="豆包AI编程">
</a>
<div class="aritcle_card_info">
<a href="/ai/732">豆包AI编程</a>
<p>豆包推出的AI编程助手</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="豆包AI编程">
<span>483</span>
</div>
</div>
<a href="/ai/732" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="豆包AI编程">
</a>
</div>
<p> </p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p><p>现在我们来看一个mysql_fetch_field实例.</p><p><?</p><pre class="brush:php;toolbar:false;">$sql = "SELECT * from a";$result = mysql_query($sql,$con);
立即学习“PHP免费学习笔记(深入)”;
while ($property = mysql_fetch_field($result))
{
echo "Field name: " . $property->name . "
";
}
立即学习“PHP免费学习笔记(深入)”;
输出的结果就是你数据表的所有字段名哦.
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号