Php + oracle Paging

Source: Internet
Author: User

The following is a paging sample program, which may seem complicated, but you only need to use it to find that "everything is so simple ":)
Example. php
$ Conn = maid ("test", "123456", "test123 ");
Include_once "pager. inc. php ";
?>
/** Start paging test */
// {Initial paging object
$ Pager = new pager ();
/** Split select id, name, age from test where age> 20 order by id desc */
$ SqlArr = array (conn => $ conn, // Database Link
Fields => "id, name, age", // query the subject sentence
Table => "test", // table name
Condition => "age> 20", // query condition
Order => "order by id desc" // sorting method
);
If (! $ Pager-> listn ($ sqlArr, 10, $ page) // 10 entries are displayed on each page.
{
$ Pager-> errno = 10;
Die ($ pager-> errmsg ());
}
//}}}
// {Data Display
For ($ I = 0; $ I <count ($ pager-> result); $ I ++)
{
$ Tmp = $ pager-> result [$ I];
Echo "id:". $ tmp [ID]."
";
Echo "name:". $ tmp [NAME]."


";
Echo "age:". $ tmp [AGE]. ""
}
//}}}
// {Display Page Link
Echo $ pager-> page. "/". $ pager-> totalpage. "total". $ pager-> total. "record ";
If ($ pager-> prev! = 0)
Echo "prev."> previous page ";
Else
Echo "Previous Page ";
If ($ pager-> next! = 0)
Echo "next."> next page ";
Else
Echo "next page ";
//}}}
?>

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.