I’m new here, and relatively new at learning php. My question is two-fold, but I’d love to have the answer to either one (both if you can). On the main page of my website, I show one blog post and then comments for that post (I attach the blog’s id # to each comment). Then, I show every comment made on previous blogs in one long list on the same page.
What I’m wondering is if there is way to put in a horizontal line or something between the comments from the different blogs? So, for instance, you see 10 comments for blog 10, line, then 5 comments for blog 8, line, then 7 comments for blog 7, and so on.
My other question is, instead of only showing a certain amount of comments (say, 15) and then having a “view all” link, how would i go about showing the first 15 and making a “More” link to show the next 15 and keep doing that?
If any of that is confusing, let me know. I really want to try to make this work, so i’d be glad to clarify anything.
Thanks!!
[php]<?php
$sql_comments = mysql_query(“SELECT * FROM users_comments WHERE room_id=’$roomid’ ORDER BY commentid DESC”);
$commenterDisplayList = “”;
while($row = mysql_fetch_array($sql_comments)){
$blogid = $row[“blogid”];
$commentid = $row[“commentid”];
$uid = $row[“user_id”];
$the_comment = $row[“the_comment”];
$comment_date = $row[“comment_date”];
$comment_date = strftime("%b %d", strtotime($comment_date));
$sql_users = mysql_query(“SELECT * FROM users WHERE id=’$uid’ LIMIT 1”);
while($row = mysql_fetch_array($sql_users)){
$uid = $row["id"];
$name = $row["name"];
$ucheck_pic = "users/$uid/pic.jpg";
$udefault_pic = "users/default.jpg";
if (file_exists($ucheck_pic)) {
$commenter_pic = "<img src=\"$ucheck_pic\" width=\"45px\" border=\"0\" />"; } else {
$commenter_pic = "<img src=\"$udefault_pic\" width=\"45px\" border=\"0\" />"; }
$commenterDisplayList .= '
<table width="97%" align="center" cellpadding="4" bgcolor="#d3cc6d">
<tr>
<td width="7%" bgcolor="#d3cc6d"><a href="user.php?id=' . $uid . '" target="_parent">' . $commenter_pic . '</a><br />
</td>
<td width="93%" bgcolor="#d3cc6d" style="line-height:1.5em;"><span style="font-size:12px;"><a href="user.php?id=' . $uid . '" target="_parent" style="text-decoration:none;color:#6c140d;">' . $name . '</a> on ' . $comment_date . '<br />
' . $the_comment . '</span></td>
</tr>
</table>';
}
}
$viewall = “”;
$cid = mysql_query("SELECT count(*) FROM users_comments WHERE room_id=’$roomid’ ");
$r = mysql_fetch_row($cid);
$comments = $r[0];
if ($comments > 15)
{
$viewall = ‘
}
else {
$viewall = “”;}
?>[/php]