我使用php.I創建螺紋註釋使用此代碼顯示螺紋comments.can任何一個可以告訴如何限制顯示螺紋commen indedation如何限制在PHP
我需要一個像螺紋註釋顯示這
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>";
}
?>
請提出這個
那麼你的問題是什麼?如何正確縮進?如何按照自己想要的方式獲取列表中的編號?如何向我們展示生成的HTML呢? – j08691 2012-02-09 17:21:45
是的,我需要顯示在正確的縮進,我張貼 – Anish 2012-02-09 17:53:16