게시판 리스트에서 댓글을 바로 보이게 하려는데요...
본문
<!--2020-07-01 코멘트 노출 추가 -->
<div style="background-color:#e1e1e1; padding:10px;">
<?php
$row=sql_fetch("select wr_name, wr_content from $write_table where wr_parent='{$list[$i][wr_id]}' and wr_is_comment = 1 order by wr_datetime desc");
echo $row[wr_name].' / ';
if($row[wr_content]) $comment=cut_str($row[wr_content],40);
else $comment=' ';
?>
<?=$comment?>
</div>
질문답변과 팁 자료에서 검색을 해서 위의 상태로 코드를 짰는데
댓글이 최신댓글 1개가 아닌 대략 5개 정도를 보이게 할려면 어디를 수정해야 할까요??
여러 고수님들의 의견이 필요합니다 ㅠ ㅠ
답변 2
$sql = " select wr_name, wr_content from $write_table where wr_parent='{$list[$i][wr_id]}' and wr_is_comment = 1 order by wr_datetime desc limit 5";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
echo $row[wr_name].' / ';
if($row[wr_content]) $comment=cut_str($row[wr_content],40);
else $comment=' ';
echo $comment;
}
$row=sql_fetch("select wr_name, wr_content from $write_table where wr_parent='{$list[$i][wr_id]}' and rownum <= 5 order by wr_datetime desc");
이렇게 수정해보세요.