$skippage=10;
$pagesize=20;
if(!$page){
$page=1;
}
$kkk=($page-1)*$pagesize;
if(!$cmd){
$qry_cnt="SELECT * FROM tech WHERE field_no=$field_no";
$qry="SELECT * FROM tech WHERE field_no=$field_no ORDER BY
wdate DESC LIMIT $kkk, $pagesize";
}else{
switch($sec){
case 1:
$qry_cnt="SELECT * FROM tech WHERE field_no=$field_no AND subject LIKE '%$string%'";
$qry="SELECT * FROM tech WHERE field_no=$field_no AND subject
LIKE '%$string%' ORDER BY wdate DESC LIMIT $kkk, $pagesize";
break;
case 2:
$qry_cnt="SELECT * FROM tech WHERE field_no=$field_no AND content LIKE '%$string%'";
$qry="SELECT * FROM tech WHERE field_no=$field_no AND content
LIKE '%$string%' ORDER BY wdate DESC LIMIT $kkk, $pagesize";
break;
}
}
$rs_cnt=mysql_query($qry_cnt);
$total_record=mysql_num_rows($rs_cnt);
$totalpage=ceil($total_record/$pagesize);
$rs=mysql_query($qry);
if(!$rs){
Error();
}
##########################################
<?
$i=$total_record-$pagesize*($kkk/$pagesize);
while($row=mysql_fetch_array($rs)){
?>
<?echo $i?>
<?
$i--;
}
?>
############################################
<!--글 번호 시작//-->
<?
$temp1=ceil($page/$skippage)-1;
$temp2=$temp1*$pagesize;
$temp3=ceil($totalpage/$skippage)-1;
$prev=$temp2;
if($prev>0){
echo "<a href='./list.php?page=1&field_no=$field_no&cmd=
$cmd&sec=$sec&string=$string'><font size=-2>[맨앞]</font></a>";
echo "<a href='./list.php?page=$prev&field_no=$field_no&cmd=
$cmd&sec=$sec&string=$string'>≪</a>";
}
$pagelist=$temp2;
for($j=1;$j<=$skippage;$j++){
$pagelist=$temp2+$j;
if($totalpage<$pagelist){
break;
}
if($pagelist<>$page){
echo "<a href='./list.php?page=$pagelist&field_no=$field_no&cmd=
$cmd&sec=$sec&string=$string'><font size=-2>[$pagelist]</font></a>";
}else {
echo "<b>".$pagelist."</b>";
}
}
$post=$temp2+$skippage+1;
if($temp1<$temp3){
echo "<a href='./list.php?page=$post&field_no=$field_no&cmd=$cmd
&sec=$sec&string=$string'>≫</a>";
echo "<a href='./list.php?page=$totalpage&field_no=$field_no&cmd=$cmd
&sec=$sec&string=$string'><font size=-2>[맨뒤]</font></a>";
}
?>
<!--글 번호 끝//-->
</pre>
'웹프로그램' 카테고리의 다른 글
PHP 썸네일 (0) | 2008.10.14 |
---|---|
PHP Session + Cookie 동작 체계 (0) | 2008.10.14 |
php 파일로 이미지 부르기 (0) | 2008.10.14 |
PHP str_replace (0) | 2008.10.14 |
이미지 액박 오류 표시 안되게 하기 (0) | 2008.10.10 |
[TIP] INC 파일 드림위버MX 디자인 뷰에 보이게하는 방법 (0) | 2008.10.08 |
HTML + CSS + Script 정리 HTML (0) | 2008.10.08 |
meta 다른 페이지로 이동 (0) | 2008.10.08 |