douyin4561 2015-04-12 12:12
浏览 29

php访问数据数组与foreach

i've got a db table which gets filled by a submit form.

the table consists of ID, usr_ID, name, and a lot more. i'm in the middle of making a custom table list in wordpress, and well.. i'm not the best at foreach.

how would i go about looping thru and only display each name and usr_id once when

example:

row 1:
id = 1, usr_id = 5, name = Alexander
row 2;
id = 2, usr_id = 4, name = james
row 3;
id = 3, usr_id = 5, name = Alexander
row 4
id = 4, usr_id = 4, name = james

how would i make a foreach statement that would print out:

usr_id = 5, name = Alexander
usr_id = 4, name = james

the purpose for the is to make each name clickable and then make a foreach statement only for the specific usr_id clicked on to see what has been submitted by each individual user

  • 写回答

4条回答 默认 最新

  • duanduan1993 2015-04-12 12:20
    关注

    how would i make a foreach statement that would print out:

    you can use this for array output:

    foreach ($query as $v) {
        echo "usr_id = ".$v['usr_id']." , name = ".$v['name'];
    }
    

    you can do this too for an array output :

    foreach ($query as $key => $list){
        echo $list['someindex'];
    }
    

    But I don't know if you want like that...

    For complete documentation about foreach, please read this... :)

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题