코드 질문드립니다.

코드 질문드립니다.

QA

코드 질문드립니다.

본문

안녕하세요

리스트페이지를 이렇게 편집해서 사용중입니다.

그런데 문제는 댓글 카운트가 안되는데 

어떻게해야 댓글을 표시할 수 있을까요 >?

 


 <form name="fboardlist" id="fboardlist" action="<?php echo G5_BBS_URL; ?>/board_list_update.php" onsubmit="return fboardlist_submit(this);" method="post">
            <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
            <input type="hidden" name="sfl" value="<?php echo $sfl ?>">
            <input type="hidden" name="stx" value="<?php echo $stx ?>">
            <input type="hidden" name="spt" value="<?php echo $spt ?>">
            <input type="hidden" name="sca" value="<?php echo $sca ?>">
            <input type="hidden" name="sst" value="<?php echo $sst ?>">
            <input type="hidden" name="sod" value="<?php echo $sod ?>">
            <input type="hidden" name="page" value="<?php echo $page ?>">
            <input type="hidden" name="sw" value="">
            <div class="tbl_head01 tbl_wrap" style="    padding: 0 15px;"> 
                <ul>
                    <?php
                        $filtered_list = []; // 필터링된 게시물을 저장할 배열
                        // 게시물 필터링
                        for ($i = 0; $i < count($list); $i++) {
                            if ($_GET['wr_11'] && $list[$i]['wr_11'] != $_GET['wr_11']) continue; // 1차 유형 필터링
                            if ($_GET['wr_12'] && $list[$i]['wr_12'] != $_GET['wr_12']) continue; // 2차 유형 필터링
                            if ($_GET['wr_13'] && $list[$i]['wr_13'] != $_GET['wr_13']) continue; // 2차 유형 필터링
                            if ($_GET['wr_14'] && $list[$i]['wr_14'] != $_GET['wr_14']) continue; // 2차 유형 필터링
                            if ($_GET['wr_15'] && $list[$i]['wr_15'] != $_GET['wr_15']) continue; // 2차 유형 필터링
                            $filtered_list[] = $list[$i]; // 조건에 맞는 게시물 저장
                        }
                        // 필터링된 게시물이 없을 경우 메시지 출력
                        if (count($filtered_list) == 0) {
                            echo '<tr><td colspan="5" class="empty_table11">등록된 고객자료 가 없습니다.</td></tr>';
                        } else {
                            // 필터링된 게시물 출력
                            foreach ($filtered_list as $index => $item) {
 
                                ?>
                                <li class="<?php if ($item['is_notice']) echo "bo_notice"; ?> <?php echo $lt_class ?>">
                                    <div class="bo_subject">
                                        <a href="<?php echo $item['href'] ?>">
                                            <h1><?php echo $item['subject'] ?></h1>
                                            <span><?php echo $item['wr_8'] ?> / <?php echo $item['wr_9'] ?></span>
                                            <p style="margin-top: 40px;"><i class="fa fa-user-o" aria-hidden="true" style="float: left; margin-top: 3px; margin-right: 5px;"></i><?php echo $item['wr_12'] ?> / <?php echo $item['ca_name'] ?>
                                            
 
                                                       <?php if ($list[$i]['comment_cnt']) { ?><span class="sound_only">댓글</span><span class="cnt_cmt"><?php echo $list[$i]['wr_comment']; ?></span><span class="sound_only">개</span><?php } ?>
 
                                            </p>
                                            <div class="bo">
                                                <?php echo $item['wr_13'] ?> / <?php echo $item['wr_14'] ?> / <?php echo $item['wr_15'] ?> 
                                            </div>
                                        </a>
                                    </div>
                                </li>
                                <?php
                            }
                        }
                        ?>            
                </ul>
            </div>
 
            <!-- 페이지 네비게이션 -->
            <?php echo $write_pages; ?>
        </form>

 

이 질문에 댓글 쓰기 :

답변 3

아래의 내용을 참고를 해보세요.

 

1. 댓글수 쿼리

 

SELECT 
    wr.*, 
    ca.ca_name,
    COUNT(c.wr_id) AS cnt_comment
FROM 
    {$write_table} AS wr
    LEFT JOIN {$comment_table} AS c ON wr.wr_id = c.wr_id AND c.wr_is_comment = 0
    LEFT JOIN {$g5['board_category_table']} AS ca ON wr.ca_name = ca.ca_name
WHERE
    wr.bo_table = '{$bo_table}'
    AND wr.wr_is_comment = 0
GROUP BY
    wr.wr_id
ORDER BY
    wr.wr_num

 

 

2. 댓글수 표시

 

<?php if ($item['cnt_comment']) { ?>
    <span class="sound_only">댓글</span>
    <span class="cnt_cmt"><?php echo $item['cnt_comment']; ?></span>
    <span class="sound_only">개</span>
<?php } ?>

 

 


<?php if ($list[$i]['comment_cnt']) { ?><span class="sound_only">댓글</span><span class="cnt_cmt"><?php echo $list[$i]['wr_comment']; ?></span><span class="sound_only">개</span><?php } ?>



<?php if ($item['comment_cnt']) { ?><span class="sound_only">댓글</span><span class="cnt_cmt"><?php echo $item['wr_comment']; ?></span><span class="sound_only">개</span><?php } ?>

해 보세요.
답변을 작성하시기 전에 로그인 해주세요.
전체 68
QA 내용 검색

회원로그인

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