mysql_fetch_array返回重复数据 [英] mysql_fetch_array returns duplicate data
本文介绍了mysql_fetch_array返回重复数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次我运行mysql_fetch_array时,都会返回具有重复值例如
every time i run mysql_fetch_array an array is returned with duplicate values e.g.
Array
(
[0] => 1
[row_id] => 1
[1] => some text
[first_field] => some text
[2] => some text
[second_field] => some text
}
但是我只想要数组中的单个结果,我尝试使用
but I only want single results in the array, I have tried using
mysql_fetch_array($data, MYSQL_ASSOC);
但这没什么区别.
推荐答案
这是 mysql_fetch_array()
的预期功能.如果您不希望有重复项",而只是具有关联数组,请使用 mysql_fetch_assoc()
.
示例:
while ($row = mysql_fetch_assoc($data)) { ... }
这篇关于mysql_fetch_array返回重复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文