new.php 페이지(?) 오류
본문
$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b, {$g5['group_table']} c where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search <> '0' and b.bo_use_search <= '{$member['mb_level']}' and c.as_show <> '0' ";
$gr_id = isset($_GET['gr_id']) ? substr(preg_replace('#[^a-z0-9_]#i', '', $_GET['gr_id']), 0, 10) : '';
if ($gr_id) {
$sql_common .= " and b.gr_id = '$gr_id' ";
}
$view = isset($_GET['view']) ? $_GET['view'] : "w";
if ($view == "w")
$sql_common .= " and a.wr_id = a.wr_parent ";
else if ($view == "c")
$sql_common .= " and a.wr_id <> a.wr_parent ";
else
$view = '';
$mb_id = isset($_GET['mb_id']) ? ($_GET['mb_id']) : '';
$mb_id = substr(preg_replace('#[^a-z0-9_]#i', '', $mb_id), 0, 20);
if ($mb_id) {
$sql_common .= " and a.mb_id = '{$mb_id}' ";
}
$sql_order = " order by a.bn_id desc ";
$sql = " select count(*) as cnt {$sql_common} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = G5_IS_MOBILE ? $config['cf_mobile_page_rows'] : $config['cf_new_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page < 1) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$group_option = '';
$sql = " select gr_id, gr_subject, as_grade, as_equal, as_min, as_max from {$g5['group_table']} where as_show <> '0' order by gr_order, gr_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
if(apms_auth($row['as_grade'], $row['as_equal'], $row['as_min'], $row['as_max'], 1)) {
continue;
}
$group_option .= "<option value=\"".$row['gr_id']."\">".$row['gr_subject'].'</option>';
}
$group_select = '<label for="gr_id" class="sound_only">그룹</label><select name="gr_id" id="gr_id"><option value="">전체그룹';
$group_select .= $group_option;
$group_select .= '</select>';
$list = array();
$sql = " select a.*, b.bo_subject, b.bo_mobile_subject, c.gr_subject, c.gr_id {$sql_common} {$sql_order} limit {$from_record}, {$rows} ";
$result = sql_query($sql);
for ($i=0,$j=0; $row=sql_fetch_array($result); $i++) {
$tmp_write_table = $g5['write_prefix'].$row['bo_table'];
if ($row['wr_id'] == $row['wr_parent']) {
// 원글
$comment = "";
$comment_link = "";
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' and wr_good >= 1 "); //추천수가 1이상인경우 출력
if($row2) {
$list[$j] = $row2;
$j++;
$name = apms_sideview($row2['mb_id'], get_text(cut_str($row2['wr_name'], $config['cf_cut_name'])), $row2['wr_email'], $row2['wr_homepage'], $row2['as_level']);
// 당일인 경우 시간으로 표시함
$wr_datetime = $row2['wr_datetime'];
$datetime = substr($row2['wr_datetime'],0,10);
$datetime2 = $row2['wr_datetime'];
if ($datetime == G5_TIME_YMD) {
$datetime2 = substr($datetime2,11,5);
} else {
$datetime2 = substr($datetime2,5,5);
}
$is_lock = false;
if (strstr($row2['wr_option'], 'secret')) {
$is_lock = true;
} else if($row2['as_shingo'] < 0) {
$is_lock = true;
}
$list[$i]['gr_id'] = $row['gr_id'];
$list[$i]['bo_table'] = $row['bo_table'];
$list[$i]['name'] = $name;
$list[$i]['comment'] = $comment;
$list[$i]['is_lock'] = $is_lock;
$list[$i]['href'] = './board.php?bo_table='.$row['bo_table'].'&wr_id='.$row2['wr_id'].$comment_link;
$list[$i]['wr_datetime'] = $wr_datetime;
$list[$i]['datetime'] = $datetime;
$list[$i]['datetime2'] = $datetime2;
$list[$i]['gr_subject'] = $row['gr_subject'];
$list[$i]['bo_subject'] = ((G5_IS_MOBILE && $row['bo_mobile_subject']) ? $row['bo_mobile_subject'] : $row['bo_subject']);
$list[$i]['wr_subject'] = $row2['wr_subject']; } }
}
$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "?gr_id=$gr_id&view=$view&mb_id=$mb_id&page=");
$write_page_rows = (G5_IS_MOBILE) ? $config['cf_mobile_pages'] : $config['cf_write_pages'];
$list_page = "?gr_id=$gr_id&view=$view&mb_id=$mb_id&page=";
어느부분이 잘못된건지
1페이지에는 추천수가 0인것이 있으므로 아무것도 안보이고
2페이지에는 추천수가 1인것이 있으므로 추천수가 1인것이 보입니다.
추천게시판을 만드려는데 페이지가 말썽입니다..
도와주세요!
답변 2
샤프심님의 질문을 확실하게 파악을 못했습니다.
일단 제가 느낀데로 적어봅니다.
https://sir.kr/qa/85573 열린이글님의 댓글을 발췌&조금수정하였습니다.
추천수 있는 게시물만 뽑아오기
★바빠서 테스트못함
/bbs/list.php
if ($sca || $stx) {
$sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows ";
} else {
$sql = " select * from {$write_table} where wr_is_comment = 0 ";
if(!empty($notice_array))
$sql .= " and wr_id not in (".implode(', ', $notice_array).") ";
$sql .= " {$sql_order} limit {$from_record}, $page_rows ";
}
if ($sca || $stx) {
$sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows ";
} else {
if($sst=='wr_good'){
$sql = " select * from {$write_table} where wr_is_comment = 0 and wr_good>0";
}else{
$sql = " select * from {$write_table} where wr_is_comment = 0 ";
}
if(!empty($notice_array))
$sql .= " and wr_id not in (".implode(', ', $notice_array).") ";
$sql .= " {$sql_order} limit {$from_record}, $page_rows ";
}
!-->
and wr_good >= 1
이걸요
and wr_good > 0
이렇게 해보세요.
>= 이 의미가 0이랑 같고 큰 값이기때문에
다 나오는걸꺼에요
답변을 작성하시기 전에 로그인 해주세요.