Thinkphp implements paging php code
// Method for generating paging // obj is the instantiated object of the paging table, and limit is the number of items displayed on the left and right of the current page. // $ Map is the where condition for paging. // $ This-> size is a variable in my own class. Public function CreatePage ($ obj, $ limit, $ map = '') {// total number of items $ totalRows = $ obj-> where ($ map) -> count (); // The total number of pages $ totalPage = (round ($ totalRows/$ limit, 0); // The current page. $ NowPage = I ('Get. P ')? I ('Get. p '): 1; if ($ nowPage> $ this-> size) {$ start = $ nowPage-$ this-> size;} else {$ start = 1 ;} if ($ totalPage> ($ nowPage + $ this-> size) {$ end = $ nowPage + $ this-> size;} else {$ end = $ totalPage ;} if ($ nowPage ==$ totalPage) {$ start = $ nowPage-$ this-> size; $ end = $ totalPage;} $ page ['totalrows '] = $ totalRows; $ page ['totalpage'] = $ totalPage; $ page ['nowpage'] = $ nowPage; $ page ['start'] = $ start; $ page ['end'] = $ end; return $ page ;// Return to the call .. Assign values.
Front-end display page
Previous Page
{$ I}
{$ I}
Next page
Script var url = "{: Q ('P', ($ page ['nowpage'] + 1 ))}"; var nowpage = "{$ page ['nowpage']}"; var totalPage = "{$ page ['totalpage']}"; jump to script
Call
$ Page = $ this-> CreatePage ($ this-> obj, $ this-> size, $ map); // this is the query operation of TP. $ Data = $ this-> obj-> where ($ map)-> field ('Del, sequence, channel', true) // focus on this. $ Page ['nowpage'] page number. // $ This-> size-> page ($ page ['nowpage'], $ this-> size)-> order ('Sequence ') -> select ()