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... :)

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题