您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

用php+oracle实现分页的示例程序

2024/3/5 20:19:56发布32次查看
oracle|程序|分页|示例
include /maya/inc/dbconn.php;
$sql=select max(rownum) from xqhtest where id$stmt=ociparse($gconn,$sql);
ociexecute($stmt);
ocifetch($stmt);
$rowcount=ociresult($stmt,1);
ocifreestatement($stmt);
echo(共有.$rowcount.条记录
\n);
$recordperpage=15; //每页显示多少条记录
$pages=ceil($rowcount/$recordperpage);  //总页数
echo(共有.$pages.页
\n);
?>
id name
//判断偏移量参数是否传递给了脚本,如果没有就使用默认值0
if (empty($offset))
{
    $offset=1;
}
$currentpage=ceil($offset/$recordperpage); //显示当前页
echo(当前页:.$currentpage.
\n);
$endset=$offset+$recordperpage;
$stmt2=ociparse($gconn,select rownum,id,name from xqhtest where id//echo select id,name from xqhtest where rownum\n;
ociexecute($stmt2);
//可以是任何sql语句,但select后面一定要有rownum,这是oracle特有的!
while (ocifetch($stmt2))
{
echo(.ociresult($stmt2,id). .ociresult($stmt2,name).
\n);
//换成你用于显示返回记录的代码
}
//要写出到所有页面的链接
print
;
for ($i=1; $i {
  $newoffset=($recordperpage*($i-1))+1;
  print $i \n;
}
print
;
$nextoffset=$recordperpage*$currentpage+1;
$prevoffset=$recordperpage*($currentpage-2)+1;
//判断是否需要上一页连接
if (($currentpage>1) && ($currentpage{
print 上一页 \n;
}
//判断是否需要下一页连接
if (($pages!=0) && ($currentpage{
  print 下一页 \n;
}
ocifreestatement($stmt2);
ocilogoff($gconn);
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product