Here is the paging sample program, which may seem tedious, but in fact you just have to use it to find that "everything is so simple":)
example.php
<?php
$conn = Ociplogon ("Test", "123456", "test123");
Include_once "pager.inc.php";
?>
<?php
/** Page Test Start * *
{{{{} initial Paging object
$pager = new Pager ();
/** the Select Id,name,age from test where age>20 the ORDER BY ID DESC Split * *
$SQLARR = Array (' conn ' => $conn,//database links
' Fields ' => "id,name,age",//query subject sentence
' Table ' => ' Test ',//list name
' Condition ' => ' age>20 ',//query conditions
' Order ' => ' orders by id desc '//sorting method
);
if (! $pager->listn ($SQLARR, $page))//per page 10
{
$pager->errno = 10;
Die ($pager->errmsg ());
}
//}}}
{{{} data display
for ($i = 0; $i < count ($pager->result); $i + +)
{
$tmp = $pager->result[$i];
echo "ID:". $tmp [' id ']. " <br> ";
echo "Name:". $tmp [' name ']. <br> ";
echo "Age:", $tmp [' age ']. " }
// }}}
{{{} Show page links
Echo $pager->page. "/" $pager->totalpage. "Total" $pager->total. " Record ";
if ($pager->prev!= 0)
echo "<a href= $PHP _self?page=". $pager->prev. " > Prev </a> ";
Else
echo "Prev";
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service