加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

php – mysql_fetch_array返回重复数据

发布时间:2020-12-11 23:52:20 所属栏目:MySql教程 来源:网络整理
导读:每次运行mysql_fetch_array时,都会返回一个包含重复值的数组,例如 Array( [0] = 1 [row_id] = 1 [1] = some text [first_field] = some text [2] = some text [second_field] = some text } 但我只想在数组中得到单个结果,我尝试过使用 mysql_fetch_array($d

每次运行mysql_fetch_array时,都会返回一个包含重复值的数组,例如

Array
(
    [0] => 1
    [row_id] => 1
    [1] => some text
    [first_field] => some text
    [2] => some text
    [second_field] => some text 
}

但我只想在数组中得到单个结果,我尝试过使用

mysql_fetch_array($data,MYSQL_ASSOC);

但这没有区别. 最佳答案 这是mysql_fetch_array()的预期功能.如果您不想使用“重复”并且只有关联数组,请使用mysql_fetch_assoc().

例:

while ($row = mysql_fetch_assoc($data)) { ... }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读