내 댓글 보기 시 추가필드 출력문제
본문
질문을 확실하게 하지못해 여러번 글을 쓰네요 ㅠㅠ 죄송합니다.
동글이님의 마이페이지 스킨을 이용하여 수정중입니다.
//new.skin.php
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 선택삭제으로 인해 셀합치기가 가변적으로 변함
$colspan = 5;
if ($is_admin) $colspan++;
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$new_skin_url.'/style.css">', 0);
$sql = " select * from g5_write_schedule where wr_is_comment = '1' order by mb_id";
$result = sql_query($sql);
$row=sql_fetch_array($result);
?>
<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="">
<?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 } ?>
<?php if ($i == 0)
echo '<tr><td colspan="'.$colspan.'" class="empty_table">게시물이 없습니다.</td></tr>';
?>
</tbody>
</table>
</div>
<?php echo $write_pages ?>
<?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>
<?php if ($is_admin) { ?>
<script>
$(function(){
$('#all_chk').click(function(){
$('[name="chk_bn_id[]"]').attr('checked', this.checked);
});
});
function fnew_submit(f)
{
f.pressed.value = document.pressed;
var cnt = 0;
for (var i=0; i<f.length; i++) {
if (f.elements[i].name == "chk_bn_id[]" && f.elements[i].checked)
cnt++;
}
if (!cnt) {
alert(document.pressed+"할 게시물을 하나 이상 선택하세요.");
return false;
}
if (!confirm("선택한 게시물을 정말 "+document.pressed+" 하시겠습니까?\n\n한번 삭제한 자료는 복구할 수 없습니다")) {
return false;
}
f.action = "./new_delete.php";
return true;
}
</script>
<?php } ?>
<!-- } 전체게시물 목록 끝 -->
schedule 게시판 게시글에 있는 댓글만 출력해서 뿌려주고싶습니다.
위 코드 적용 시 내가 어느 게시글에 댓글을 달았는지는 정상적으로 출력이 되나
댓글 작성시에 추가필드(wr_7)가 작성 댓글과 전혀 매치가 안되고 최근 댓글의 w_7필드만 전부 뿌려주고 있는 현상이 생깁니다.
sql 상 데이터는 전혀 문제가 없고요.
wr_is_comment = '1'라고 지정해준 이유는 게시글이 아닌 댓글만 추리기 위해서 였는데 맞게 한건지 사실 잘 모르겠습니다 ㅠㅠㅠ
!-->
답변 2
$row=sql_fetch_array($result); <---이게 틀렸습니다
while($row= sql_fetch_array($result)){
$wrid= $row['wr_parent'];
$list_wr7[$wrid] = $row['wr_7'];
}
[<?php echo $row['wr_7'] ?>] ----->수정
[<?php echo $list_wr7[$list[$i][wr_id]];?>]
그런데 댓글이 2개 이상일 때는??
그리고 댓글 추출 코드는 사용하지않을 모든 페이지 게시물의 댓글을 추출하게 되어있는데
비효율적인 것은 차치하고 나중에 게시물 및 댓글이 많아지면 아주 안좋을테죠?
해당 페이지에 있는 wr_id만 모아서 해당 댓글만 추출하는 코드를 연구하세요
!-->
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 안에서
...
<td class="td_name" style="background-color:red;">[<?php echo $row['wr_7'] ?>]</td>
...
이렇게 하면 wr_7이 똑같은 값만 리스트에 나오는 건 당연합니다.
하여간에 질문 내용을 이해를 못 하겠습니다.
답변을 작성하시기 전에 로그인 해주세요.