oracle| Program | pagination | example <body>
?
Include "/maya/inc/dbconn.php";
$sql = "Select Max (rownum) from xqhtest where id<50";
$stmt =ociparse ($gConn, $sql);
Ociexecute ($stmt);
Ocifetch ($stmt);
$rowcount =ociresult ($stmt, 1);
Ocifreestatement ($stmt);
Echo ("Shared". $rowcount. " Record <br>\n ");
$recordperpage = 15; How many records are displayed per page
$pages =ceil ($rowcount/$recordperpage); Total pages
Echo ("Shared". $pages. " Page <br>\n ");
Determine if the offset parameter is passed to the script, and if not, use the default value 0
if (empty ($offset))
{
$offset = 1;
}
$currentpage =ceil ($offset/$recordperpage); Show Current Page
Echo ("Current page:". $currentpage. " <br>\n ");
$endset = $offset + $recordperpage;
$stmt 2=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<." $offse T. " <br>\n ";
Ociexecute ($stmt 2);
can be any SQL statement, but there must be rownum behind the Select, which is unique to Oracle!
while (Ocifetch ($stmt 2))
Determine if a next page connection is required
if ($pages!=0) && ($currentpage < $pages))
{
Print "<a href=\" $PHP _self?offset= $nextoffset \ "> Next </a> \ n";
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.