관리자 페이지에서 누적 게시물 페이지를 만드려고 합니다.
본문
----- 업데이트 -----
$list를 찍어보니
array 에 0 부터 시작이 아니고
17부터 시작인데..
(그래서 list[$i] 값이 아무것도 찍히지 않았던것 같습니다.)
이걸 0부터 시작으로 만들어줄수 있나요!?
아 i를 0으로 선언해줘야...ㅠㅠㅠㅠ
----- 업데이트 끝 -----
게시판은 report(신고) 라는 테이블이구요..
여기있는 중복된 자료를 제외하고 wr_12(게시판ID), wr_20(원글ID)
누적수를 좀 출력하고 싶은데..ㅠ
$list[$i] 값이 while 밖에서는 출력이 안됩니다 @_@
if($page_rows > 0) {
while ($row = sql_fecth_array($result)){
$list[$i] = get_list(~~~~~);
// 여기 안에서는 $list[$i] 값이 출력됩니다.
}
}
list.php 를 보고 만든건데..
이 아래코드는 report_sum.php 의 전체 소스입니다.
출력할때 $row로 한거는 무시해주시구요
$list[$i]['wr_name'] 값도 안나옵니다 ㅠ
<?php
$sub_menu = "850010";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'w');
$g5['title'] = '누적신고';
include_once('./admin.head.php');
$colspan = 8;
// 게시물 ////////////////////////////////////////////////////
$write_table = 'g5_write_report';
$sop = strtolower($sop);
if ($sop != 'and' && $sop != 'or')
$sop = 'and';
$stx = trim($stx);
if ($sca || $stx) {
$sql_search = get_sql_search($sca, $sfl, $stx, $sop);
// 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)
$sql = " select MIN(wr_num) as min_wr_num from {$write_table} ";
$row = sql_fetch($sql);
$min_spt = (int)$row['min_wr_num'];
if (!$spt) $spt = $min_spt;
$sql_search .= " and (wr_num between {$spt} and ({$spt} + {$config['cf_search_part']})) ";
// 원글만 얻는다. (코멘트의 내용도 검색하기 위함)
// 라엘님 제안 코드로 대체 http://sir.kr/g5_bug/2922
$sql = " SELECT COUNT(DISTINCT `wr_parent`) AS `cnt` FROM {$write_table} WHERE {$sql_search} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
/*
$sql = " select distinct wr_parent from {$write_table} where {$sql_search} ";
$result = sql_query($sql);
$total_count = sql_num_rows($result);
*/
} else {
$sql_search = "";
$sql = " SELECT count(a.wr_12) AS cnt
FROM (
SELECT count(wr_20), wr_12 FROM `g5_write_report` WHERE wr_is_comment = 0 GROUP BY wr_12, wr_20
) AS a";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
}
$sql_board = " SELECT * FROM g5_board WHERE bo_table = 'report'";
$board = sql_fetch($sql_board);
$page_rows = $board['bo_page_rows'];
$list_page_rows = $board['bo_page_rows'];
if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
// 년도 2자리
$today2 = G5_TIME_YMD;
$total_page = ceil($total_count / $page_rows); // 전체 페이지 계산
$from_record = ($page - 1) * $page_rows; // 시작 열을 구함
// 정렬에 사용하는 QUERY_STRING
$qstr2 = 'bo_table='.$bo_table.'&sop='.$sop;
// 정렬
// 인덱스 필드가 아니면 정렬에 사용하지 않음
// if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {
// sst = 검색정렬필드
// sca = 카테고리
// sfl = 검색필드
// stx = 검색어
// sod = 검색오름, 내림차순
// sop = 검색 or, and 오퍼레이터
// spt = 검색 파트(구간)
if (!$sst) {
if ($board['bo_sort_field']) {
$sst = $board['bo_sort_field'];
} else {
$sst = "wr_18, wr_15";
$sod = "";
}
} else {
// 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16)
// 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요.
// $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
$sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
}
if(!$sst)
$sst = "wr_18, wr_15"; // wr_18 = 신고일, wr_15 = 신고횟수
if ($sst) {
$sql_order = " GROUP BY wr_20, wr_11 ORDER BY {$sst} {$sod} ";
}
if ($sca || $stx) {
$sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows ";
} else {
$sql = " SELECT *,
GROUP_CONCAT(DISTINCT ca_name ORDER BY ca_name) AS reason, GROUP_CONCAT(DISTINCT wr_15 ORDER BY wr_15) AS report_cnt from {$write_table}
WHERE wr_is_comment = 0 ";
$sql .= " {$sql_order} limit {$from_record}, $page_rows ";
}
// 페이지의 공지개수가 목록수 보다 작을 때만 실행
if($page_rows > 0) {
$result = sql_query($sql);
$k = 0;
while ($row = sql_fetch_array($result))
{
// 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
if ($sca || $stx)
$row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");
$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
if (strstr($sfl, 'subject')) {
$list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
}
$list[$i]['is_notice'] = false;
$list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
$list[$i]['num'] = $list_num - $k;
$i++;
$k++;
}
}
$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, './board.php?bo_table='.$bo_table.$qstr.'&page=');
////////////////////////////////////////////////////
// 페이징
/*
$sql_cnt = "SELECT COUNT(DISTINCT wr_id) as cnt FROM g5_write_report WHERE wr_is_comment = 0";
$row_cnt = sql_fetch($sql_cnt);
$total_count = $row_cnt['cnt'];
$page_rows = 10;
$page = ($_GET['page'] < 1) ? 1 : $_GET['page'];
$from_record = ($page - 1) * $page_rows;
$total_page = ceil($total_count / $page_rows);
$url = "./report_sum.php";
$adm_pages = get_paging($page_rows, $page, $total_page, $url, $add="");
*/
?>
<div class="tbl_head01 tbl_wrap total_report_wrap">
<table>
<caption>누적 신고</caption>
<thead>
<tr>
<th scope="col" class="td_parent">번호</th>
<th scope="col" class="td_name">글쓴이</th>
<th scope="col" class="td_subject">제목</th>
<th scope="col" class="td_reason">사유</th>
<th scope="col" class="td_reg">등록일</th>
<th scope="col" class="td_report">신고일</th>
<th scope="col" class="td_board">게시판</th>
<th scope="col" class="td_count">신고횟수</th>
</tr>
</thead>
<tbody>
<?php
//for ($i = 0; $row = sql_fetch_array($result); $i++) {
for ($i=0; $i<count($list); $i++) {
$bg = 'bg' . ($i % 2);
?>
<tr class="<?php echo $bg; ?>">
<td scope="row" class="td_parent">
<?php echo $from_record + $i + 1; ?>
</td>
<td scope="row" class="td_name">
<?php echo $list[$i]['wr_name'] ?>(<?php echo $row['mb_id']?>)
</td>
<td scope="row" class="td_subject">
<?php echo $row['wr_subject'] ?>
</td>
<td scope="row" class="td_reason">
<?php echo $row['reason']; ?>
</td>
<td scope="row" class="td_reg">
<?php echo $row['wr_datetime'] ?>
</td>
<td scope="row" class="td_report">
<?php echo $row['wr_18'] ?>
</td>
<td scope="row" class="td_board">
<?php echo $row['wr_11'] ?>
</td>
<td scope="row" class="td_count">
<?php
$report_cnt = explode(',', $row['report_cnt']);
echo max($report_cnt);
?>
</td>
</tr>
<?php } ?>
<?php if ($i == 0) { echo '<tr><td colspan="'.$colspan.'" class="empty_table">신고된 게시물이 없습니다.</td></tr>'; } ?>
</tbody>
</table>
<?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'].'?'.$qstr.'&page='); ?>
<form name="fsearch" id="fsearch" class="" method="get">
<label for="sfl" class="sound_only">검색대상</label>
<select name="sfl" id="sfl">
<option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id"); ?>>회원아이디</option>
<option value="wr_name"<?php echo get_selected($_GET['sfl'], "wr_name"); ?>>글작성자</option>
<option value="wr_11"<?php echo get_selected($_GET['sfl'], "wr_11"); ?>>게시판</option>
<option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject"); ?>>제목</option>
<option value="ca_name"<?php echo get_selected($_GET['sfl'], "ca_name"); ?>>사유</option>
<option value="wr_datetime"<?php echo get_selected($_GET['sfl'], "wr_datetime"); ?>>등록일</option>
<option value="wr_18"<?php echo get_selected($_GET['sfl'], "wr_18"); ?>>신고일</option>
<option value="wr_15"<?php echo get_selected($_GET['sfl'], "wr_15"); ?>>누적신고횟수</option>
</select>
<label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
<input type="text" name="stx" value="<?php echo $stx ?>" id="stx" required class="required frm_input">
<input type="submit" value="검색" class="btn_submit">
</form>
</div>
<?php
include_once('./admin.tail.php');
?>
답변 1
제생각엔 어짜피 그누보드 게시판 테이블양식을 따라가는것이라면
따로 스킨을 만드셔서 손을 보시는게 좋을것 같습니다.
저렇게 짜버리면 뒤죽박죽 섞여버려서 나중에 수정할때 작동원리를 모르는 상황에서
꽤나 고생하실것 같아요
답변을 작성하시기 전에 로그인 해주세요.