1
2
3
4$pagesize = 3;//设置每页显示数目
5
6//计算总记录数
7$rs_num = "select count(*) as id from table";
8$rs_num = odbc_exec($conn_id,$rs_num);
9$rs_num = odbc_result($rs_num,"id");
10
11//计算总页数
12$pagecount = $rs_num / $pagesize;
13$pagecount1 = intval($pagecount);//将总页数取整
14$compare = $pagecount - $pagecount1;
15switch ($compare){
16case "0":
17$pagecount = $pagecount1;//总页数
18break;
19default :
20$pagecount1++;
21$pagecount = $pagecount1;//总页数
22break;
23};
24if ($pagecount == 0)$pagecount++;
25
26
27$fpages = $pages-1;
28$bpages = $pages+1;
29
30
31
1<table>
2<tr>
3<td>
4共```
5 echo $pagecount
6```页
if($pages != 1)echo "<a href="show.php3?pages=1">";
首页
if($pages != 1)echo "</a>";
if($pages != 1)echo "<a href='show.php3?pages=".$fpages."'>";
前页
if($pages != 1)echo "</a>";
if($pages != $pagecount)echo "<a href='show.php3?pages=".$bpages."'>";
后页
if($pages != $pagecount)echo "</a>";
if($pages != $pagecount)echo "<a href='show.php3?pages=".$pagecount."'>";
1尾页```
2 if($pages != $pagecount)echo "</a>";
$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)){
};
1
//关闭连接
odbc_close($conn_id);
1
2
3【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】