只从MySQL获取字段名
现在,当我运行以下查询 SELECT * FROM table 时,我得到以下响应
array(1) {
[0]=>
array(36) {
[0]=>
string(5) "31764"
["id"]=>
string(5) "31764"
...
}
...
}
正如您所看到的,我得到了 2 个相同的数据(“0”和“id”)。有什么办法只能获取“id”而不是“0”吗?
Right now when I run the following query SELECT * FROM table
I get the following response
array(1) {
[0]=>
array(36) {
[0]=>
string(5) "31764"
["id"]=>
string(5) "31764"
...
}
...
}
As you can see I am getting 2 of the same data ("0" and "id"). Is there any way I can only get "id" and not "0"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看
mysql_fetch_array()
<的文档/a>,第二个参数允许您指定返回哪种类型的数组:或者您可以使用
mysql_fetch_assoc()
。Check the documentation of
mysql_fetch_array()
, the second argument allows you to specify what kind of array to return:Or you could just use
mysql_fetch_assoc()
.你可以像这样编写sql:
从表中选择“id”
它会回来
you can write the sql just like :
SELECT 'id' FROM table
it wil just return