search
Homephp教程php手册php oracle数据库实现分页

php oracle数据库实现分页

Jun 13, 2016 am 09:49 AM
oraclephpone timeintroduceaboutPaginationandaccomplishdatabasearticleof

本文章来介绍一下关于php和orace数据库实现数据库的分页功能,下面有需要的同学可以看看吧。

 代码如下 复制代码




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 rownumn";
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";
}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools