채택완료

최신글 답변 카운트

2016-09-13 (화) 15:32:32 3,573

list.skin에서 원글의 답변을 카운트하는 방법을 도움으로 알아내어 출력까지 확인을 하여서

똑같이 메인화면의 최신글목록 부분에도 출력을 하려고 list.skin에서 썻던 소스를 똑같이

가져와서 해당 원하는 자리에 값을 넣었는데 빈공간으로 나오네요... 뭐 따로 추가해야할께 있는건가요??

밑은 latest.skin.php 스킨입니다.

<ul>
    <?php for ($i=0; $i<count($list); $i++) {
        // 원글의 옆에 답글이 몇개인지를 표시하는 sql 구분 쿼리
        $reply = sql_fetch(" select count(*) as cnt from ".$write_table." where wr_reply != '' and wr_num = '{$list[$i]['wr_num']}' ");
        if($list[$i]['wr_reply']) $reply_cnt = '';
        else $reply_cnt = '['.$reply['cnt'].']';

            $reply_href = G5_BBS_URL.'/write.php?w=r&amp;bo_table='.$bo_table.'&amp; wr_id='.$list[$i]['wr_id'].$qstr;
            //$list_href = G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&amp; wr_num='.$list[$i]['wr_num'].'&page=';
            $list_href = G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&sca=&sop=and&sfl=wr_num&stx='.-($list[$i]['wr_num']);
           
          
            echo "<a  target='iframe_show' id='latest_st' onclick='showRe(".$list[$i]['wr_id'].")'  href=\"".$list_href."\">";
                // 원글 옆의 답글 링크 부분
                // 관리자로 로그인 시 보여지게 셋팅
    if($is_admin) {
        if(!$list[$i]['wr_reply'])
                echo "&nbsp;".$list[$i]['subject'].$reply_cnt."<a target='iframe_show' class='first_re' href='".$reply_href."'>추가</a>";
            } else {
                if(!$list[$i]['wr_reply'])
            echo "&nbsp;".$list[$i]['subject'].$reply_cnt."";
           
        }      
        echo "</a>";
        ?>
        <li> 
             <?php
            //답변글만 출력
            if($is_admin){
            if($list[$i]['wr_reply']){
                echo "<a target='iframe_show'  onclick='showRe(".$list[$i]['wr_id'].")' class='re".$list[$i]['wr_1']."' id='latest_re'href=\"".$list[$i]['href']."\" >".$list[$i]['icon_reply']."&nbsp;&nbsp;";
                echo $list[$i]['subject']."";
                echo "</a><a target='iframe_show' class='re".$list[$i]['wr_1']."' id='second_re' href='".$reply_href."'>추가</a>";
                }
            }
            else{
                if($list[$i]['wr_reply']){
                    echo "<a target='iframe_show' onclick='showRe(".$list[$i]['wr_id'].")'  class='re".$list[$i]['wr_1']."'  id='latest_re'href=\"".$list[$i]['href']."\" >".$list[$i]['icon_reply']."&nbsp;&nbsp;";
                    echo $list[$i]['subject']."";
                    echo "</a>";
                }
            }
            ?>

</li>

위의 for문 바로 밑에     

$reply = sql_fetch(" select count(*) as cnt from ".$write_table." where wr_reply != '' and wr_num = '{$list[$i]['wr_num']}' ");
        if($list[$i]['wr_reply']) $reply_cnt = '';
        else $reply_cnt = '['.$reply['cnt'].']'; 

이 부분이 답변 카운트를 하는 부분이고  

원하는 부분 ul쪽 에 $list[$i]['subject'] 바로 뒤에 $reply_cnt를 입력하였는데 list에서와는 다르게

값이 출력이 되질 않네요 ㅜ 무슨 문제인걸까요 ㅜ 부탁드리겠습니다 ㅜ 

답변 1개

채택된 답변
+20 포인트
2016-09-13 (화) 17:17:59

http://sir.kr/qa/142715 에서 댓글로 답변해 드렸습니다. 

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