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

내 댓글 보기 시 추가필드 출력문제 채택완료

굼떠 4년 전 조회 1,195

질문을 확실하게 하지못해 여러번 글을 쓰네요 ㅠㅠ 죄송합니다.

동글이님의 마이페이지 스킨을 이용하여 수정중입니다.

https://sir.kr/g5_skin/1330?sfl=wr_subject%7C%7Cwr_content&stx=%EB%A7%88%EC%9D%B4%ED%8E%98%EC%9D%B4%EC%A7%80

 

</p>

<p>//new.skin.php</p>

<p><?php

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가</p>

<p>// 선택삭제으로 인해 셀합치기가 가변적으로 변함

$colspan = 5;

if ($is_admin) $colspan++;</p>

<p>// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨

add_stylesheet('<link rel="stylesheet" href="'.$new_skin_url.'/style.css">', 0);</p>

<p>$sql = " select * from g5_write_schedule where wr_is_comment = '1' order by mb_id";

$result = sql_query($sql);

$row=sql_fetch_array($result);</p>

<p>?>

<style>

strong {display:inline-block;}

</style>

<!-- 전체게시물 목록 시작 { -->

<form name="fnewlist" id="fnewlist" method="post" action="#" onsubmit="return fnew_submit(this);">

<input type="hidden" name="sw"       value="move">

<input type="hidden" name="view"     value="<?php echo $view; ?>">

<input type="hidden" name="sfl"      value="<?php echo $sfl; ?>">

<input type="hidden" name="stx"      value="<?php echo $stx; ?>">

<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">

<input type="hidden" name="page"     value="<?php echo $page; ?>">

<input type="hidden" name="pressed"  value=""></p>

<p><?php if ($is_admin) { ?>

<div class="admin_new_btn">

    <button type="submit" onclick="document.pressed=this.title" title="선택삭제" class="btn_b01 btn"><i class="fa fa-trash-o" aria-hidden="true"></i><span class="sound_only">선택삭제</span></button>

</div>

<?php } ?>

<div class="tbl_head01 tbl_wrap">

    <table>

    <thead>

    <tr>

        <?php if ($is_admin) { ?>

        <th scope="col" class="chk_box">

            <input type="checkbox" id="all_chk" class="selec_chk">

            <label for="all_chk">

                <span></span>

                <b class="sound_only">목록 전체</b>

            </label>

        </th>

        <?php } ?>

        <th scope="col">제목</th>

        <th scope="col">접수상태</th>

        <th scope="col">수강일</th>

    </tr>

    </thead>

    <tbody>

    <?php

    for ($i=0; $i<count($list); $i++)

    {

        $num = $total_count - ($page - 1) * $config['cf_page_rows'] - $i;

        $gr_subject = cut_str($list[$i]['gr_subject'], 20);

        $bo_subject = cut_str($list[$i]['bo_subject'], 20);

        $wr_subject = get_text(cut_str($list[$i]['wr_subject'], 80));

    ?>

    <tr>

        <?php if ($is_admin) { ?>

        <td class="td_chk chk_box">

            <input type="checkbox" name="chk_bn_id[]" value="<?php echo $i; ?>" id="chk_bn_id_<?php echo $i; ?>" class="selec_chk">

            <label for="chk_bn_id_<?php echo $i; ?>">

                <span></span>

                <b class="sound_only"><?php echo $num?>번</b>

            </label>

            <input type="hidden" name="bo_table[<?php echo $i; ?>]" value="<?php echo $list[$i]['bo_table']; ?>">

            <input type="hidden" name="wr_id[<?php echo $i; ?>]" value="<?php echo $list[$i]['wr_id']; ?>">

        </td>

        <?php } ?>

        <td><a href="/bbs/board.php?bo_table=<?php echo $list[$i]['bo_table']; ?>&wr_id=<?php echo $list[$i]['wr_id']; ?>" target="_parent" class="new_tit"><?php echo $wr_subject ?> <strong>[<?php echo $list[$i]['ca_name']; ?>]</strong></a></td>

        <td class="td_name" style="background-color:red;">[<?php echo $row['wr_7'] ?>]</td>

        <td class="td_date"><?php echo $list[$i]['wr_1'] ?></td>

    </tr>

    <?php }  ?></p>

<p>    <?php if ($i == 0)

        echo '<tr><td colspan="'.$colspan.'" class="empty_table">게시물이 없습니다.</td></tr>';

    ?>

    </tbody>

    </table>

</div></p>

<p><?php echo $write_pages ?></p>

<p><?php if ($is_admin) { ?>

<div class="admin_new_btn">

    <button type="submit" onclick="document.pressed=this.title" title="선택삭제" class="btn_b01 btn"><i class="fa fa-trash-o" aria-hidden="true"></i><span class="sound_only">선택삭제</span></button>

</div>

<?php } ?>

</form></p>

<p><?php if ($is_admin) { ?>

<script>

$(function(){

    $('#all_chk').click(function(){

        $('[name="chk_bn_id[]"]').attr('checked', this.checked);

    });

});</p>

<p>function fnew_submit(f)

{

    f.pressed.value = document.pressed;</p>

<p>    var cnt = 0;

    for (var i=0; i<f.length; i++) {

        if (f.elements[i].name == "chk_bn_id[]" && f.elements[i].checked)

            cnt++;

    }</p>

<p>    if (!cnt) {

        alert(document.pressed+"할 게시물을 하나 이상 선택하세요.");

        return false;

    }</p>

<p>    if (!confirm("선택한 게시물을 정말 "+document.pressed+" 하시겠습니까?\n\n한번 삭제한 자료는 복구할 수 없습니다")) {

        return false;

    }</p>

<p>    f.action = "./new_delete.php";</p>

<p>    return true;

}

</script>

<?php } ?>

<!-- } 전체게시물 목록 끝 -->

 </p>

<p>

 

schedule 게시판 게시글에 있는 댓글만 출력해서 뿌려주고싶습니다.

위 코드 적용 시 내가 어느 게시글에 댓글을 달았는지는 정상적으로 출력이 되나

댓글 작성시에 추가필드(wr_7)가 작성 댓글과 전혀 매치가 안되고 최근 댓글의  w_7필드만 전부 뿌려주고 있는 현상이 생깁니다.

 

sql 상 데이터는 전혀 문제가 없고요. wr_is_comment = '1'라고 지정해준 이유는 게시글이 아닌 댓글만 추리기 위해서 였는데 맞게 한건지 사실 잘 모르겠습니다 ㅠㅠㅠ 

 

 

 

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

답변 2개

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

</p>

<p><span class="token variable">$row</span><span class="token operator">=</span><span class="token function">sql_fetch_array</span><span class="token punctuation">(</span><span class="token variable">$result</span><span class="token punctuation">)</span><span class="token punctuation">; <---이게 틀렸습니다</span></p>

<p><span class="token punctuation">while($row= sql_fetch_array($result)){ </span></p>

<p><span class="token punctuation">  $wrid= $row['wr_parent'];</span></p>

<p><span class="token punctuation">  $list_wr7[</span>$wrid] = $row['wr_7'];</p>

<p> }</p>

<p> </p>

<p>[<span class="token php language-php"><span class="token delimiter important"><?php</span> <span class="token keyword keyword-echo">echo</span> <span class="token variable">$row</span><span class="token punctuation">[</span><span class="token single-quoted-string string">'wr_7'</span><span class="token punctuation">]</span> <span class="token delimiter important">?></span></span>] ----->수정</p>

<p>[<span class="token php language-php"><span class="token delimiter important"><?php</span> <span class="token keyword keyword-echo">echo</span> <span class="token variable">$list_wr7[$list[$i][wr_id]];</span><span class="token delimiter important">?></span></span>]</p>

<p>

그런데 댓글이 2개 이상일 때는??

그리고 댓글 추출 코드는 사용하지않을 모든 페이지 게시물의 댓글을 추출하게 되어있는데

비효율적인 것은 차치하고 나중에 게시물 및 댓글이 많아지면 아주 안좋을테죠?

해당 페이지에 있는 wr_id만 모아서 해당 댓글만 추출하는 코드를 연구하세요

 

 

 

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

답변에 대한 댓글 2개

굼떠
4년 전
정말 감사합니다.
굼떠
4년 전
정말 감사합니다.

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

loop 바깥에서
$sql = " select * from g5_write_schedule where wr_is_comment = '1' order by mb_id";
$result = sql_query($sql);
$row=sql_fetch_array($result);

이렇게 하고

loop 안에서

...

        []
...

이렇게 하면 wr_7이 똑같은 값만 리스트에 나오는 건 당연합니다.

 

하여간에 질문 내용을 이해를 못 하겠습니다.

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

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

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

로그인