Php implements a paging class, and php implements a paging class.
File Name: page. class. php
Code-level Parsing
<? Phpclass Page {private $ total; // total number of records in the data table private $ listRows; // The number of lines displayed on each Page is private $ limit; private $ uri; private $ pageNum; // page number private $ config = array ('header' => "records", "prev" => "Previous Page", "next" => "next page ", "first" => "first page", "last" => "last page"); private $ listNum = 8; /** $ total * $ listRows */public function _ construct ($ total, $ listRows = 10, $ pa = "") {$ this-> total = $ total; $ this-> listRows = $ listRows; $ this-> uri = $ this-> getUri ($ pa); $ thi S-> page =! Empty ($ _ GET ["page"])? $ _ GET ["page"]: 1; $ this-> pageNum = ceil ($ this-> total/$ this-> listRows ); $ this-> limit = $ this-> setLimit ();} private function setLimit () {return "Limit ". ($ this-> page-1) * $ this-> listRows. ", {$ this-> listRows}";} private function getUri ($ pa) {$ url = $ _ SERVER ["REQUEST_URI"]. (strpos ($ _ SERVER ["REQUEST_URI"], '? ')? '':"? "). $ Pa; $ parse = parse_url ($ url); if (isset ($ parse ["query"]) {parse_str ($ parse ['query'], $ params ); unset ($ params ["page"]); $ url = $ parse ['path']. '? '. Http_build_query ($ params);} return $ url;} function _ get ($ args) {if ($ args = "limit") return $ this-> limit; elsereturn null;} private function start () {if ($ this-> total = 0) return 0; elsereturn ($ this-> page-1) * $ this-> listRows + 1;} private function end () {return min ($ this-> page * $ this-> listRows, $ this-> total );} private function first () {if ($ this-> page = 1) $ html. = ''; else $ html. = "<a href = '{$ this-> uri} & page = 1'> {$ this-> co Nfig ["first"]} </a> "; return $ html;} private function prev () {if ($ this-> page = 1) $ html. = ''; else $ html. = "<a href = '{$ this-> uri} & page = ". ($ this-> page-1 ). "'>{$ this-> config [" prev "]} </a>"; return $ html;} private function pageList () {$ linkPage = ""; $ inum = floor ($ this-> listNum/2); for ($ I = $ inum; $ I >=1; $ I --) {$ page = $ this-> page-$ I; if ($ page <1) continue; $ linkPage. = "<a href = '{$ this-> uri} & page = {$ page}' >{$ page} </a>" ;}$ link Page. = "{$ this-> page}"; for ($ I = 1; $ I <= $ inum; $ I ++) {$ page = $ this-> page + $ I; if ($ page <= $ this-> pageNum) $ linkPage. = "<a href = '{$ this-> uri} & page = {$ page}' >{$ page} </a>"; elsebreak ;} return $ linkPage;} private function next () {if ($ this-> page ==$ this-> pageNum) $ html. = ''; else $ html. = "<a href = '{$ this-> uri} & page = ". ($ this-> page + 1 ). "'>{$ this-> config [" next "]} </a>"; return $ html;} private function last () {if ($ this-> page ==$ This-> pageNum) $ html. = ''; else $ html. = "<a href = '{$ this-> uri} & page = ". ($ this-> pageNum ). "'>{$ this-> config [" last "]} </a>"; return $ html;} private function goPage () {return '<input type = "text" onkeydown = "javascript: if (event. keyCode = 13) {var page = (this. value> '. $ this-> pageNum. ')? '. $ This-> pageNum. ': this. value; location = \''. $ this-> uri. '& page = \' + page + \ '} "value = "'. $ this-> page. '"style =" width: 25px "> <input type =" button "value =" GO "onclick =" javascript: var page = (this. previussibling. value> '. $ this-> pageNum. ')? '. $ This-> pageNum. ': this. previussibling. value; location = \''. $ this-> uri. '& page = \' + page + \ '">';} function fpage ($ display = array (0, 1, 2, 3, 4, 5, 6, 7, 8 )) {$ html [0] = "total <B >{$ this-> total} </B >{$ this-> config [" header "]}"; $ html [1] = "per page <B> ". ($ this-> end ()-$ this-> start () + 1 ). "</B>, <B> {$ this-> start ()}-{$ this-> end ()} </B> "; $ html [2] = "<B >{$ this-> page}/{$ this-> pageNum} </B> page "; $ html [3] = $ this-> first (); $ html [4] = $ this-> prev (); $ html [5] = $ this-> pageList (); $ html [6] = $ this-> next (); $ html [7] = $ this-> last (); $ html [8] = $ this-> goPage (); $ fpage = ''; foreach ($ display as $ index) {$ fpage. = $ html [$ index] ;}return $ fpage ;}}
[URGENT] php paging is a php paging class. A detailed example should be provided.
I have a simple and easy-to-use paging class. You can try it. There are also online instances.
Just ask me if you have any questions.
Instance address: www.bnet.com.cn/list-810-0-0-0-2.htm
Reference: blog.everalan.com/293.html
Thinkphp30 has a paging class, which is really easy to use. But how to perform partial refresh is to click the previous page. only partial refresh is performed on the next page.
You can set the page to be refreshed to an iframe framework, or use ajax to send requests for paging.