我正在使用 php 创建一个线程注释。我使用此代码来显示线程注释。任何人都可以告诉如何限制显示线程commen indedation
我需要这样
comment 1
-->comment 1.1
-->comment 1.1.1
-->comment 1.2
-->comment 1.2.1
-->comment 1.2.2
comment 2
-->comment 2.1
-->comment 2.1.2
但不是这样
comment 1
-->comment 1.1
-->comment 1.1.1
-->comment 1.2
-->comment 1.2.1
-->comment 1.2.1.1
comment 2
-->comment 2.1
-->comment 2.1.2
我的php代码是这样的
<div id='wrapper'>
<ul>
<?php
$q = "select idvideo,discussion from video_discussion where
video_discussion.idvideo = 972 AND parent_id = 0
$r = mysql_query($q);
while($row = mysql_fetch_assoc($r)):
getComments($row);
endwhile;
?>
</ul>
并在功能页面上
<?php
function getComments($row) {
echo "<li class='comment'>";
echo "<div class='aut'>".$row['discussion']."</div>";
echo "<a href='#comment_form' class='reply' id='".$row['idvideo_discussion']."'>Reply</a>";
$q=" select idvideo,discussion from video_discussion where video_discussion.idvideo = 972 and parent_id =".$row['idvideo_discussion'].";
$r = mysql_query($q);
if(mysql_num_rows($r)>0)
{
echo "<ul>";
while($row = mysql_fetch_assoc($r)) {
getComments($row);
}
echo "</ul>";
}
echo "</li>";
}
?>
请为此提出解决方案