$pagesize = 3;//設定每頁顯示數目
//計算總記錄數
$rs_num = "select count(*) as id from table";
$rs_num = odbc_exec($conn_id,$rs_num);
$rs_num = odbc_result($rs_num,"id");
//計算總頁數
$pagecount = $rs_num / $pagesize;
$pagecount1 = intval($pagecount);//將總頁數取整
$compare = $pagecount - $pagecount1;
switch ($compare){
case "0":
$pagecount = $pagecount1;//總頁數
break;
default :
$pagecount1++;
$pagecount = $pagecount1;//總頁數
break;
};
if ($pagecount == 0)$pagecount++;
$fpages = $pages-1;
$bpages = $pages+1;
?>
$firstshow = ($pages-1)*$pagesize+1;//確定每頁的第一條記錄
//找出第一條記錄的記錄號
$query_string = "SELECT * FROM table Order By id DESC";
$query_string = odbc_exec($conn_id,$query_string);
odbc_fetch_into($query_string,$firstshow,&$idarea);
$idsql = $idarea[0];
//定位尋找
if ($pages == $pagecount) {
$rs = "SELECT * FROM table where id <= '".$idsql."' Order By id DESC";
}else{
$rs = "SELECT Top ".$pagesize." * FROM table where id <= '".$idsql."' Order By id DESC";
};
$rs = odbc_exec($conn_id,$rs);
//顯示記錄
while(odbc_fetch_row($rs)){
};
?>
//關閉串連
odbc_close($conn_id);
?>
【本文著作權歸作者與奧索網共同擁有,如需轉載,請註明作者及出處】