갤러리 게시판 추출 분류시 이상 ( 쿼리 포함 재질문)

갤러리 게시판 추출 분류시 이상 ( 쿼리 포함 재질문)

QA

갤러리 게시판 추출 분류시 이상 ( 쿼리 포함 재질문)

본문

아래 질문 올렸는데, 체택하기를 눌러서 다시 올립니다. ^^;;

---------------------------

 

안녕하세요. 그누초보가 또 질문드리러 왔습니다. ^^;

 

별도의 php 파일에서 게시글을 불러와서 사용중인데요.

게시글의 분류가 제대로 출력이 되지 않는 현상이 있습니다.

뭔가 기초적인 내용을 잘 못 한 것 같은데 잘 모르겠네요.

 

아래와 같이 게시판의 직접주소(?)를 링크하면 분류가 제대로 정렬이 됩니다.

http://sedamnhc.cafe24.com/proot/bbs/board.php?bo_table=gallery&sca=Mordern 

 

그런데 아래와 같이 php 소스를 통해 일부만 불려드리는 경우에는

http://sedamnhc.cafe24.com/proot/?sca=Mordern#gallery 

특정 날짜 이후로는 보이지가 않습니다.

#gallery의 경우 A태그의 책갈피 기능을 적용한 것입니다. 

 

그누보드, php, css 등의 지식이 없이

 

과거에 잠시 배운 html태그와 c언어의 기초 지식만으로 접근하려니 한계가 있네요.

기초 강좌도 틈틈히 보고 있지만, 시간이 부족해서요...

 

혹시 원인을 아시는 분이 계실까요?

 

구조는 인덱스.php  >> main_galllery >> display_gallery 

 

 

★ 인덱스에서 불러들인 main_galllery


			<nav id="inner" width="95%">
				<table border='0' align='center'><tr>
					<td><a href="<?php echo G5_URL; ?>#gallery"><span>All</span></a>  </td>
					<td><a href="<?php echo G5_URL; ?>?sca=Basic#gallery"><span>Basic</span></a>  </td>
					<td><a href="<?php echo G5_URL; ?>?sca=Mordern#gallery"><span>Mordern</span></a>  </td>
					<td><a href="<?php echo G5_URL; ?>?sca=Romantic#gallery"><span>Romantic</span></a>  </td>
					<td><a href="<?php echo G5_URL; ?>?sca=Platinum#gallery"><span>Platinum</span></a></td>
				</tr></table>
			</nav>
<?php require(G5_THEME_PATH.'/main/display_gallery.php');?>

 

★ display_gallery.php (쿼리 부분)


<?php
$bo_table = 'gallery';
$board_skin_url = G5_THEME_URL . '/skin/board/basic';


$write = array();
$write_table = "";
if ($bo_table) {
    $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
    if ($board['bo_table']) {
        set_cookie("ck_bo_table", $board['bo_table'], 86400 * 1);
        $gr_id = $board['gr_id'];
        $write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    }
}


$width = $board['bo_table_width'];
if ($width <= 100)
    $width .= '%';
else
    $width .='px';


// 분류 선택 또는 검색어가 있다면
$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'];
} else {
    $sql_search = "";


    $total_count = $board['bo_count_write'];
}


$page_rows = $board['bo_page_rows'];
$list_page_rows = $board['bo_page_rows'];


if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)


// 년도 2자리
$today2 = G5_TIME_YMD;


$list = array();
$i = 0;
$notice_count = 0;
$notice_array = array();


$total_page  = ceil($total_count / $page_rows);  // 전체 페이지 계산
$from_record = ($page - 1) * $page_rows; // 시작 열을 구함


// 0 으로 나눌시 오류를 방지하기 위하여 값이 없으면 1 로 설정
$bo_gallery_cols = $board['bo_gallery_cols'] ? $board['bo_gallery_cols'] : 1;
$td_width = (int)(100 / $bo_gallery_cols);


// 정렬
// 인덱스 필드가 아니면 정렬에 사용하지 않음
//if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {
if (!$sst) {
    if ($board['bo_sort_field']) {
        $sst = $board['bo_sort_field'];
    } else {
        $sst  = "wr_num, wr_reply";
        $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_num, wr_reply";


if ($sst) {
    $sql_order = " order by {$sst} {$sod} ";
}


if ($sca || $stx) {
    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $total_count ";
} 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}, $total_count ";
}


// 페이지의 공지개수가 목록수 보다 작을 때만 실행
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++;
    }
}


$nobr_begin = $nobr_end = "";
if (preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {
    $nobr_begin = '<nobr>';
    $nobr_end   = '</nobr>';
}


// RSS 보기 사용에 체크가 되어 있어야 RSS 보기 가능 061106
$rss_href = '';
if ($board['bo_use_rss_view']) {
    $rss_href = './rss.php?bo_table='.$bo_table;
}


$stx = get_text(stripslashes($stx));


include_once(G5_LIB_PATH.'/thumbnail.lib.php');
?>
<script>
$(function(){


    $("#bo_gall .gall_li").slice(0, 9).show(); // select the first ten


    $(".more").click(function(e){ // click event for load more
        e.preventDefault();
        $("#bo_gall .gall_li:hidden").slice(0, 3).slideDown(1000); // select next 10 hidden divs and show them
        if($("#bo_gall .gall_li:hidden").length == 0){ // check if any hidden divs still exist
            alert("더이상 이미지가 없습니다."); // alert if there are none left
        }
    });


	$(window).resize();


	$('#view_gallery .close').css({
		'cursor':'pointer'
	}).on('click', function() {
		$('#view_gallery > .content').html('');
		$('#view_gallery').css('display', 'none');
	});


	$(document).on('click', '#view_gallery > .content > .view_image_list > li', function() {
		var img = $(this).attr('view');
		$('#view_gallery > .content > .view_image').html(img);
	});
});


$(window).resize(function(){
	$('.content').css({position:'absolute'}).css({//$('.content').outerWidth(true)) / 2,   $('.content').outerHeight(true)) / 2
		left: ($(window).width() - 800) / 2, 
		top: ($(window).height() - 850) / 2
	});


	$('.close').css({position:'absolute'}).css({//$('.content').outerWidth(true)) / 2,   $('.content').outerHeight(true)) / 2
		left: ($(window).width() + 800) / 2,
		top: ($(window).height() - 895) / 2
	});
});


function view(bo_table, wr_id){
	$.ajax({
		url: g5_url+"/theme/sedam0/main/view_gallery.php",
		type: "POST",
		data: {'bo_table' : bo_table, 'wr_id' : wr_id},
		dataType: "text",
		error : function(request, status, error){
			var msg = "code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error;
			msg += "\n\n현재 오류입니다.\n위 내용을 알려주시면 도움이 됩니다.";
			alert(msg);
			$('.wrap-loading').addClass('display-none');
		},success: function(data) {
			$('#view_gallery').css('display', 'block');
			$('#view_gallery > .content').html(data);
			$('.wrap-loading').addClass('display-none');
		},beforeSend:function(){
			$('.wrap-loading').removeClass('display-none');
		}
	});
}
</script>

 

이 질문에 댓글 쓰기 :

답변 2

$sql 변수를 echo로 출력하신 후 

 

 

실제로 db에서 실행해보세요..

 

 

아마 sql 쿼리문에 limit로 제한이 걸려있을꺼 같아요

$sql 변수 출력한 결과는 아래와 같이 나오네요. 분류 선택하면 -11 +1000 이라고 나오는 이 부분이 문제인 거 같은데 뭔지 모르겠네요.. 혹시 알아보실까요?

select * from g5_write_gallery where wr_is_comment = 0 order by wr_num, wr_reply limit 0, 55

select distinct wr_parent from g5_write_gallery where ca_name = 'Basic' and (wr_num between -11 and (-11 + 1000)) order by wr_num, wr_reply limit 0, 0

위 질문에서 궁금한것이...

> 아래와 같이 게시판의 직접주소(?)를 링크하면 분류가 제대로 정렬이 됩니다.
> http://sedamnhc.cafe24.com/proot/bbs/board.php?bo_table=gallery&sca=Mordern

위 방법으로 정렬이 잘된다면 display_gallery.php 프로그램을 구현할 필요없이
main_gallery 에서 bbs/board.php?bo_table=galley&sca=분류명#gallery 로 직접 링크해주시면 될것 같은데

이방법을 사용하지 않으시면 뭔 다른 이유라도 있으신가요?... 

원페이지 형식으로 구현중이라 그렇습니다.
여러페이지를 헤더에 넣을 수가 없어서(방법을 모릅니다.)
인덱스 페이지에서 php로 제작된 여러 섹션 페이지를 포함시킨 방식으로 하였거든요... ^^;;
전체적이고 기초적인 내용을 모르고 요래 조래 짜집기 하다보니 이렇게 흘러왔네요. 하하하..

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT