我有从查询返回的以下数据,每一个名字是一个项目:解析一行多列php
id name comment
1 FF hey
1 FF hey back!
2 LL
3 PP i think its great!
3 PP me too
3 PP I'm not sure
4 TT
5 II
6 KK yesterday is the new tomorrow
当我显示出来,每一个“项目”有一个ID,并显示在资料核实使用LI。
正如你可以看到,虽然有时也有多个意见为“项目”,每一个单独的行
我想要做的就是显示每个项目,然后显示每个项目下的意见,如果有任何。所以,我不能组由作为注释部分是唯一的查询阶段,任何事情,但需要在小组阶段显示
所以目前有:
while ($row = mysql_fetch_array($result)){
echo '<li><div class=className><div class=itemName>'.$row[name].'</div>';
if($row[comment]){
echo '<div class=newRow>'.$row[comment].'</div>';
}
echo '</div></li>';
}
现在,这是没有好,因为这将为同一项目生成多个显示,每个显示下有一个注释。
我能做到这一点,或者我应该在数据带来的不同?
理想的结果是例如
FF LL PP etc etc etc
hey i think its great!
hey back! me too
I'm not sure
作为第一行说,每个名称是一个项目 – 2013-03-17 15:22:51