Example. php
Copy codeThe Code is as follows:
<? Php
$ Conn = maid ("test", "123456", "test123 ");
Include_once "pager. inc. php ";
?>
Copy codeThe Code is as follows:
<? 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 connection
'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']. "<br> ";
Echo "name:". $ tmp ['name']. "<br> ";
Echo "age:". $ tmp ['age']. "}
//}}}
// {Display Page Link
Echo $ pager-> page. "/". $ pager-> totalpage. "total". $ pager-> total. "record ";
If ($ pager-> prev! = 0)
Echo "<a href = $ PHP_SELF? Page = ". $ pager-> prev."> previous page </a> ";
Else
Echo "Previous Page ";
If ($ pager-> next! = 0)
Echo "<a href = $ PHP_SELF? Page = ". $ pager-> next."> next page </a> ";
Else
Echo "next page ";
//}}}
?>
<? @ OCILogoff ($ conn)?>