php mysql显示结果集中的选定记录
I have a query which fetches replies to comments. so my first query has them comments, e.g.
comment 1 <BR>
reply 1<BR>
comment 2<BR>
comment 3<BR>
reply 1<BR>
reply 2<BR>
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?
我有一个查询来获取对评论的回复。 我的第一个查询有他们的评论, e.g。 p>
comment 1&lt; BR&gt;
&amp; nbsp; 回复1&lt; BR&gt;
comment 2&lt; BR&gt;
comment 3&lt; BR&gt;
&amp; nbsp; 回复1&lt; BR&gt;
&amp; nbsp; 回复2&lt; BR&gt;
&amp; nbsp; 回复2&lt; BR&gt;
code> pre>
评论3有3个回复。 我做了一个查询来从我的数据库中获取 commentID code>
in(1,2,3)的所有回复。 这将带给我所有有效的回复。 p>
现在问题是当我想显示结果时,我在 code>循环时启动并浏览所有注释。 p>
如何在 while code>循环中获取该特定注释的选定回复? p>
div>
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];
}