当前位置:Gxlcms > PHP教程 > 用ODBC的分页显示_PHP教程

用ODBC的分页显示_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

$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);
?>


【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316505.htmlTechArticle?php $pagesize = 3;//设置每页显示数目 //计算总记录数 $rs_num = select count(*) as id from table; $rs_num = odbc_exec($conn_id,$rs_num); $rs_num = odbc_result($rs_num,i...

人气教程排行