리스트에서 댓글을 출력하기 위해 아래와 같이 했는데 댓글은 출력이 되는데 대글에 대한 답글이 출력이 안됨~~디비에는 wr_comment_reply 에 A 로 입력되어 있음~~
Copy
<?php
// 댓글 조회
$sql = "SELECT * FROM {$g5['write_prefix']}{$bo_table}
WHERE wr_parent = '{$list[$i]['wr_id']}' AND wr_is_comment = 1
ORDER BY wr_comment_reply ASC, wr_datetime ASC"; // wr_comment_reply로 정렬
$comments = sql_query($sql);
while ($comment = sql_fetch_array($comments)) {
$comment_content = $comment['wr_content'];
$comment_content = applyEmoticons($comment_content, $emoticons); // 이모티콘 적용
if ($comment['wr_option'] == 'secret' && !$is_member) {
$comment_content = '<i class="fa fa-lock" aria-hidden="true"></i> 비밀글입니다.';
}
// wr_comment_reply 값이 있으면 답글로 간주
$is_reply = !empty($comment['wr_comment_reply']); // wr_comment_reply 값이 있으면 true
$cmt_depth = $is_reply ? strlen($comment['wr_comment_reply']) * 20 : 0; // 들여쓰기 깊이 계산
// 답글의 깊이에 따라 들여쓰기 적용
$cmt_depth = $is_reply ? (strlen($comment['wr_comment_reply']) * 20) : 0;
?>
<div class="comment" style="margin-left: <?php echo $cmt_depth; ?>px;">
<div class="comment-header">
<span class="comment-author"><?php echo get_text($comment['wr_name']); ?></span>
<span class="comment-date"><?php echo $comment['wr_datetime']; ?></span>
</div>
<div class="comment-content">
<?php echo $comment_content; ?>
</div>
</div>
|
답변 3개 / 댓글 3개
채택된 답변
+20 포인트
2025-01-15 (수) 16:52:53
wr_parent 값은 동일하게 존재하나요?
해당 데이터값이 어떻게 보이는지 정확히 알수 없기에 쿼리 구조상은 나와야 하는게 맞는걸로 보입니다.
답변에 대한 댓글 1개
2025-01-15 (수) 18:15:20
블랙캣77
2025-01-15 (수) 16:53:14
혹시나 해서 해당쿼리 제가 따로 해봐도 나오는게 정상이네요. 말씀하신데로 둘 다 wr_is_comment 1이라서 나와야 하는데 정렬순서는 생각하신데로가 아닐수 있습니다. 다 나오는데 정렬이 제대로 안된건지 확인을 한번 해보셔야 할 거 같습니다.
답변에 대한 댓글 1개
2025-01-15 (수) 18:16:11
네~답변 감사합니다~~
wr_parent 값이 잘못 입력이 되어서 정상 입력되게 수정해서 이젠 답글이 출력됩니다~
wr_parent 값이 잘못 입력이 되어서 정상 입력되게 수정해서 이젠 답글이 출력됩니다~
블랙캣77
2025-01-15 (수) 15:42:44
일단 쿼리 자체로는 나와야하는게 맞을거 같은데 쿼리를 phpmyadmin이나 외부프로그램으로 해봐도 동일하게 안나오시나요?
답변에 대한 댓글 1개
2025-01-15 (수) 16:09:32
답변감사합니다~~
댓글은 wr_is_comment = 1 인 것을 출력하는 것 아닌가요?
답글도 wr_is_comment =1 이기 때문에 출력되어야할듯한데~~
그냥 댓글은 출력되는데 답글은 안되네요~~
phpmyadmin 으로 아직 해보지 않았어요~ 설치를 하지 않아서요~~
댓글은 wr_is_comment = 1 인 것을 출력하는 것 아닌가요?
답글도 wr_is_comment =1 이기 때문에 출력되어야할듯한데~~
그냥 댓글은 출력되는데 답글은 안되네요~~
phpmyadmin 으로 아직 해보지 않았어요~ 설치를 하지 않아서요~~
답변을 작성하려면 로그인이 필요합니다.
wr_parent 값이 달라져서 수정했습니다~이제 답글이 출력됩니다~