테스트 사이트 - 개발 중인 베타 버전입니다

게시판 리스트에서 댓글을 바로 보이게 하려는데요... 채택완료

하하하00 5년 전 조회 2,141

 

 

                        <!--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].'&nbsp;/&nbsp;';

 if($row[wr_content]) $comment=cut_str($row[wr_content],40);

 else $comment='&nbsp;';

                        ?>

                        <?=$comment?>

                       </div>

 

질문답변과 팁 자료에서 검색을 해서 위의 상태로 코드를 짰는데

댓글이 최신댓글 1개가 아닌 대략 5개 정도를 보이게 할려면 어디를 수정해야 할까요??

여러 고수님들의 의견이 필요합니다 ㅠ ㅠ 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
dragon
5년 전

$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;
   
}

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

하하하00
5년 전
dragon님! 답변 감사합니다 ^^
알려주신대로 했더니 출력이 되네요!!
며칠 동안 고민한건데 덕분에 해결되었어요!
감사합니다~~~

댓글을 작성하려면 로그인이 필요합니다.

5년 전

 $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");

 

이렇게 수정해보세요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

하하하00
5년 전
드라칸님! 답변 감사합니다!!
그런데 출력이 안되네요 ㅠ ㅠ
아무튼 답변 감사합니다~

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인