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

페이지네이션 오류 채택완료

JN나비 3년 전 조회 2,716

안녕하세요. 존경하는 고수님들. 바쁘신 시간이지만 혹시 도움을 주실 수 있으시면 답변 부탁드립니다.

 

영카트에서 전체 상품이 나타는 페이지를 제작하려 하는데

페이지네이션에 오류가 생기네요

 

 

총 21개 상품이고 20개 상품씩 끊어서 페이지를 매기는데

1페이지도 21개 상품, 2페이지도 21개 상품이 전부 나옵니다.

 

아래 코드를 넣어놓았습니다.

많은 조언 부탁드립니다.

 

 

 

 

</p>

<p><?php

include_once('./_common.php');</p>

<p>$g5['title'] = '전체상품';

include_once(G5_THEME_MSHOP_PATH.'/shop.head.php');</p>

<p>?></p>

<p>

<div id="sidx">

<section class="sct_wrap">

    <header>

        <h2><a href="#">전체상품</a></h2>

    </header>

    <?php

//---------------- 여기부터

 $skin_file = G5_MSHOP_SKIN_PATH .'/main.10.skin.php'; //스킨명(기존 것을 사용하거나 새로이 만들거나)

 $item_mod = 4; //한줄당 갯수

 $item_rows = 5; //줄 수

 $items = $item_mod * $item_rows;

 $item_width= 480; //이미지 가로

 $item_height = 480; //이미지 세로

 $sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' order by it_update_time desc ";

        if ($page < 1) $page = 1;

        // 시작 레코드 구함

        $from_record = ($page - 1) * $items;

 $list = new item_list($skin_file, $item_mod , $item_rows , $item_width, $item_height);

 $list->set_query($sql);

//---------- 여기까지

    $list->set_is_page(true);

    $list->set_from_record($from_record);

    $list->set_view('it_img', true);

    $list->set_view('it_name', true);

    $list->set_view('it_basic', true);

    $list->set_view('it_cust_price', true);

    $list->set_view('it_price', true);

    $list->set_view('it_icon', true);

    echo $list->run();

    

    

       // where 된 전체 상품수

        $total_count = $list->total_count;

        // 전체 페이지 계산

        $total_page  = ceil($total_count / 20);</p>

<p>    ?></p>

<p>    <?php

$qstr1 .='&sort='.$sort.'&sortodr='.$sortodr;

echo get_paging($config['cf_mobile_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'].'?'.$qstr1.'&page=');

?>

</section>

</div>

<?php

include_once(G5_THEME_MSHOP_PATH.'/shop.tail.php');

?></p>

<p>

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

답변 1개

플래토
3년 전

</p>

<pre>
<code>$sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' order by it_update_time desc ";
        if ($page < 1) $page = 1;
        // 시작 레코드 구함
        $from_record = ($page - 1) * $items;</code></pre>

<p><code>

이부분을

다음과 같이 변경해보세요

</span></font></p>

<p> </p>

<pre>
<code>        if ($page < 1) $page = 1;
        // 시작 레코드 구함
        $from_record = ($page - 1) * $items;</code></pre>

<p><code>$sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' order by it_update_time desc limit $from_record, $item_rows  "; </code></p>

<p><code>

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

답변에 대한 댓글 7개

J
JN나비
3년 전
오히려 5개만 불러와집니다 ㅠ
플래토
3년 전
제가 수정하라고 말씀드린 쿼리의 맨뒤부분을
limit $from_record, $item_rows 에서
limit $from_record, $items
로 변경해보세요
J
JN나비
3년 전
그러면 딱 20개만 불러와져요 ㅠㅠ 아래 페이지 넘버는 아예 나오지도 않습니다.
플래토
3년 전
제가 수정하라고 한부분이
보여주신 로직의 일부분인건 맞죠?
설마 하단을다 삭제하신건 아니죠?

삭제하신게 아니라면
페이지가 안나올리가 없을텐데요

[code]
<?php
include_once('./_common.php');
$g5['title'] = '전체상품';
include_once(G5_THEME_MSHOP_PATH.'/shop.head.php');
?>

<div id="sidx">
<section class="sct_wrap">
<header>
<h2><a href="#">전체상품</a></h2>
</header>
<?php
//---------------- 여기부터
$skin_file = G5_MSHOP_SKIN_PATH .'/main.10.skin.php'; //스킨명(기존 것을 사용하거나 새로이 만들거나)
$item_mod = 4; //한줄당 갯수
$item_rows = 5; //줄 수
$items = $item_mod * $item_rows;
$item_width= 480; //이미지 가로
$item_height = 480; //이미지 세로
if ($page < 1) $page = 1;
// 시작 레코드 구함
$from_record = ($page - 1) * $items;
$sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' order by it_update_time desc
limit $from_record, $items "; // 이부분만 변경한겁니다.

$list = new item_list($skin_file, $item_mod , $item_rows , $item_width, $item_height);
$list->set_query($sql);
//---------- 여기까지
$list->set_is_page(true);
$list->set_from_record($from_record);
$list->set_view('it_img', true);
$list->set_view('it_name', true);
$list->set_view('it_basic', true);
$list->set_view('it_cust_price', true);
$list->set_view('it_price', true);
$list->set_view('it_icon', true);
echo $list->run();


// where 된 전체 상품수
$total_count = $list->total_count;
// 전체 페이지 계산
$total_page = ceil($total_count / 20);
?>
<?php
$qstr1 .='&sort='.$sort.'&sortodr='.$sortodr;
echo get_paging($config['cf_mobile_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'].'?'.$qstr1.'&page=');
?>
</section>
</div>
<?php
include_once(G5_THEME_MSHOP_PATH.'/shop.tail.php');
?>
[/code]
위와같이 하신게 맞나요?
J
JN나비
3년 전
네 전체 그대로 복사 해서 붙여넣어도 안되네요;;
플래토
3년 전
set_query
를 사용하셔서
작동하는 결과값을 찍어보면서 확인하셔야 할것같네요

답변란으로 추측하면서 답으로는 쉽지않을것같고
실제로 echo문으로 total_record값을 찍어보면서 역추적으로 접근해서 확인하시는수밖에 없을것 같습니다.
어딘가 조건이 줄어들게 작동하는것을 찾아서 해결해야할것으로 보여지네요
J
JN나비
3년 전
네 우선 댓글 달아주셔서 감사합니다 ^^ 계속 연구해보겠습니다.

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

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

로그인