搜索
首页php教程php手册用php+oracle实现分页的示例程序

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");

?>



//判断偏移量参数是否传递给了脚本,如果没有就使用默认值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("\n");

   //换成你用于显示返回记录的代码
}
//要写出到所有页面的链接
print "
id name
".ociresult($stmt2,"ID")." ".ociresult($stmt2,"NAME")."


";


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

 



声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境