繁体中文
设为首页
加入收藏
当前位置:PHP技术首页 >> PHP基础 >> 用php+oracle实现分页的示例程序

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

2005-02-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
关键字:示例 程序 oracle php

include "/maya/inc/dbconn.PHP";

$sql="select max(rownum) from xqhtest where id

idname

//判断偏移量参数是否传递给了脚本,如果没有就使用默认值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<50 and rownum<".$endset." minus select rownum,id,name from xqhtest where id<50 and rownum<".$offset);

//echo "SELECT id,name FROM xqhtest WHERE rownum<".$endset." minus select id,name from xqhtest where rownum<".$offset."

\n";

ociexecute($stmt2);

//可以是任何sql语句,但select后面一定要有rownum,这是oracle特有的!

while (ocifetch($stmt2))

{

echo("".ociresult($stmt2,"ID")."".ociresult($stmt2,"NAME")."\n");

//换成你用于显示返回记录的代码

}

//要写出到所有页面的链接

print "

";

for ($i=1; $i 1) && ($currentpage<=$pages))

{

print "上一页 \n";

}

//判断是否需要下一页连接

if (($pages!=0) && ($currentpage

责任编辑:admin
相关文章