现在,当我运行以下查询时 SELECT * FROM table
我得到以下响应
array(1) {
[0]=>
array(36) {
[0]=>
string(5) "31764"
["id"]=>
string(5) "31764"
...
}
...
}
如您所见,我得到了 2 个相同的数据(“0”和“id”)。有什么办法只能得到“id”而不是“0”吗?
最佳答案
查看 mysql_fetch_array()
的文档,第二个参数允许您指定要返回的数组类型:
The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.
或者您可以只使用 mysql_fetch_assoc()
.
关于php - 只从 MySQL 获取字段名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8830122/