[기본] paging(페이징) > 학습

본문 바로가기

사이트 내 전체검색

411,566명이 방문해 주셨습니다.

[  PHP  ] [기본] paging(페이징)

작성일 20-07-21 13:06

페이지 정보

작성자IPFT 조회 4,577회 댓글 2건

본문

$page_set = 20;
$block_set = 10; 

$sql = "select count(*) as total from 테이블명 $gu";
$row = sql_fetch($sql);

$total = $row[total]; 

$total_page = ceil ($total / $page_set); 
$total_block = ceil ($total_page / $block_set); 

if (!$page) $page = 1; 
$block = ceil ($page / $block_set); 

$limit_idx = ($page - 1) * $page_set;

$num001=$total-($page-1)*$page_set;

$sql = "select * from 테이블명 $gu limit $limit_idx, $page_set";
$result = sql_query($sql);

for ($i=0; $row=sql_fetch_array($result); $i++){
	리스트
}


$first_page = (($block - 1) * $block_set) + 1; 
$last_page = min ($total_page, $block * $block_set); 
 
$prev_page = $page - 1; 
$next_page = $page + 1; 
 
$prev_block = $block - 1; 
$next_block = $block + 1; 
 
$prev_block_page = $prev_block * $block_set; 
$next_block_page = $next_block * $block_set - ($block_set - 1); 
 

echo ($prev_page > 0) ? "<a onclick='location.href=\"$PHP_SELF?gu=".$_GET['gu']."&listgu0=".$_GET['listgu0']."&guxyz=".$_GET['guxyz']."&page=$prev_page&adm_p2p=".$_GET['adm_p2p']."\"'><</a> " : "";
echo ($prev_block > 0) ? "<a pg_prev'onclick='location.href=\"$PHP_SELF?gu=".$_GET['gu']."&listgu0=".$_GET['listgu0']."&guxyz=".$_GET['guxyz']."&page=$prev_block_page&adm_p2p=".$_GET['adm_p2p']."\"'>&nbsp;<<&nbsp;</a> " : "";
 
for ($i=$first_page; $i<=$last_page; $i++) {
echo ($i != $page) ? "<a href='$PHP_SELF?gu=".$_GET['gu']."&listgu0=".$_GET['listgu0']."&guxyz=".$_GET['guxyz']."&page=$i&adm_p2p=".$_GET['adm_p2p']."'>$i</a> " : "<a >$i</a> ";
}
 
echo ($next_block <= $total_block) ? "<a  pg_next'onclick='location.href=\"$PHP_SELF?gu=".$_GET['gu']."&listgu0=".$_GET['listgu0']."&guxyz=".$_GET['guxyz']."&page=$next_block_page&adm_p2p=".$_GET['adm_p2p']."\"'>>></a>" : "";
echo ($next_page <= $total_page) ? "<a  onclick='location.href=\"$PHP_SELF?gu=".$_GET['gu']."&listgu0=".$_GET['listgu0']."&guxyz=".$_GET['guxyz']."&page=$next_page&adm_p2p=".$_GET['adm_p2p']."\"'> >></a>" : "";

댓글목록

IPFT님의 댓글

IPFT 작성일

설명이 필요하신분은 댓글 또는 REQUEST에 글남겨주세요. ^^

IPFT님의 댓글

IPFT 작성일

$first_page = (($block - 1) * $block_set) + 1;
$last_page = min ($total_page, $block * $block_set);
 
$prev_page = $page - 1;
$next_page = $page + 1;
 
$prev_block = $block - 1;
$next_block = $block + 1;
 
$prev_block_page = $prev_block * $block_set;
$next_block_page = $next_block * $block_set - ($block_set - 1);
 

echo ($prev_page > 0) ? "<a onclick='location.href=\"$PHP_SELF?listgu0=".$_GET['listgu0']."&page=$prev_page\"'><</a> " : "";
echo ($prev_block > 0) ? "<a pg_prev'onclick='location.href=\"$PHP_SELF?listgu0=".$_GET['listgu0']."&page=$prev_block_page\"'>&nbsp;<<&nbsp;</a> " : "";
 
for ($i=$first_page; $i<=$last_page; $i++) {
echo ($i != $page) ? "<a href='$PHP_SELF?listgu0=".$_GET['listgu0']."&page=$i'>$i</a> " : "<a >$i</a> ";
}
 
echo ($next_block <= $total_block) ? "<a  pg_next'onclick='location.href=\"$PHP_SELF?listgu0=".$_GET['listgu0']."&page=$next_block_page\"'>>></a>" : "";
echo ($next_page <= $total_page) ? "<a  onclick='location.href=\"$PHP_SELF?listgu0=".$_GET['listgu0']."&page=$next_page\"'> >></a>" : "";

Copyright © 소유하신 도메인. All rights reserved.