리스트에서 댓글의 답글이 출력이 안됨~

리스트에서 댓글의 답글이 출력이 안됨~

QA

리스트에서 댓글의 답글이 출력이 안됨~

본문

리스트에서 댓글을 출력하기 위해 아래와 같이 했는데 댓글은 출력이 되는데 대글에 대한 답글이 출력이 안됨~~디비에는 wr_comment_reply 에 A 로 입력되어 있음~~


 
<?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

wr_parent 값은 동일하게 존재하나요?
해당 데이터값이 어떻게 보이는지 정확히 알수 없기에 쿼리 구조상은 나와야 하는게 맞는걸로 보입니다.

일단 쿼리 자체로는 나와야하는게 맞을거 같은데 쿼리를 phpmyadmin이나 외부프로그램으로 해봐도 동일하게 안나오시나요?

답변감사합니다~~
 댓글은 wr_is_comment = 1 인 것을 출력하는 것 아닌가요?
답글도 wr_is_comment =1 이기 때문에 출력되어야할듯한데~~
그냥 댓글은 출력되는데 답글은 안되네요~~
phpmyadmin 으로 아직 해보지 않았어요~ 설치를 하지 않아서요~~

혹시나 해서 해당쿼리 제가 따로 해봐도 나오는게 정상이네요. 말씀하신데로 둘 다 wr_is_comment 1이라서 나와야 하는데 정렬순서는 생각하신데로가 아닐수 있습니다. 다 나오는데 정렬이 제대로 안된건지 확인을 한번 해보셔야 할 거 같습니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 127,565 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT