This is part of the code for a comments script i'm working on. This part displays the replies to the parent comment. It's a threaded comment system and I want the replies in a table to move over to the right (a threaded look). The problem now is when the Reply to a Reply is shown, the $tblwidth just starts at 20 again.... I need it to start at 40 for the reply to the reply (where DisplayReplies is repeated) and from there increase 20.
So basicly:
[Parent Comment]
- [Relpy] (#2) - the table would be 20px
-- [Reply To #2] (#3) -table would be 40px
--- [Reply To #3] - the table would be 60px
function DisplayReplies ($tid, $mode, $order=0, $thold=0, $level=0, $dummy=0) {
global $datetime, $user, $cookie, $bgcolor1, $reasons, $anonymous, $anonpost, $commentlimit, $prefix, $textcolor2;
$comments = 0;
$result = mysql_query("select tid, pid, lid, date, name, email, url, host_name, subject, comment, score, reason, number from download_comments where pid = $tid order by date, tid");
if ($mode == 'nested') {
echo"$icountreplies1";
for($tblwidth=20;$tblwidth>=0;$tblwidth=$tblwidth+20) {
if (list($r_tid, $r_pid, $r_lid, $r_date, $r_name, $r_email, $r_url, $r_host_name, $r_subject, $r_comment, $r_score, $r_reason, $r_number) = mysql_fetch_row($result)) {
if($r_score >= $thold) {
if (!isset($level)) {
} else {
if (!$comments) {
echo "";
// $tblwidth -= 5;
}
}
$comments++;
if (!eregi("[a-z0-9]",$r_name)) $r_name = $anonymous;
if (!eregi("[a-z0-9]",$r_subject)) $r_subject = "["._NOSUBJECT."]";
// HIJO enter hex color between first two appostrophe for second alt bgcolor
$r_bgcolor = ($dummy%2)?"":"#E6E6D2";
echo "<a name=\"$r_tid\">";
formatTimestamp($r_date);
$icountreplies = "select tid from nuke_download_comments where lid=$r_lid and pid=$r_tid";
$icountreplies2 = mysql_query("$icountreplies");
$icountreplies1 = mysql_num_rows($icountreplies2);
echo"$tblwidth<div class=\"commenthead\" style=\"margin-left:";
echo "$tblwidth; px;";
echo"\">$r_comment</div>";
if ($icountreplies1 == "1") {
echo"<table width=\"$tblwidth%\" border=\"0\" cellspacing=\"0\">
<tr>
<td width=\"100%\"><font size=\"2\"><b>::</b> <a href=><b>$icountreplies1 Reply</b></a></tr></td></table></div>";
} elseif ($icountreplies1 > "1") {
echo"<div align=\"right\"><table width=\"$tblwidth%\" border=\"0\" cellspacing=\"0\">
<tr>
<td width=\"100%\"><font size=\"2\"><b>::</b> <a href=><b>$icountreplies1 Replies</b></a></tr></td></table></div>";
} else {
echo"";
}
echo"</div><BR>";
DisplayReplies($r_tid, $mode, $order, $thold, $level+1, $dummy+1, $tblwidth);
}
} else {
break;
}
}