duanph1978 2012-08-08 17:08
浏览 24
已采纳

php mysql显示结果集中的选定记录

I have a query which fetches replies to comments. so my first query has them comments, e.g.

comment 1 <BR>
  &nbsp; reply 1<BR>
comment 2<BR>
comment 3<BR>
   &nbsp; reply 1<BR>
   &nbsp; reply 2<BR>
   &nbsp; reply 2<BR>

Comment 3 has 3 replies. I make one query to fetch all replies from my database where the commentID in (1,2,3) . This will bring me all valid replies.

Now the problem is when I want to display the results, I start a while loop and go through all the comments.

How do I get the selected replies just for that particular comment while in the while loop?

  • 写回答

1条回答 默认 最新

  • doubo6658 2012-08-08 17:10
    关注

    Assuming you stored the replies in a multidimensional array lets say $array_replies, this is how youd do it

    for ($i=0; $i<count($array_replies[$commentID]); $i++) {
       echo $array_replies[$commentID][$i];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 html5+css有人可以帮吗?
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?