Php article paging implementation code
| Php implements pagination of the article content and automatically pagination based on the content length. if you want to study this part of the page, refer to it.
The code is as follows:
$ Conlen) {$ j ++; $ listat [$ j] = $ conlen; break;} $ endat = strpos ($ content, "\ n", $ lookat ); if ($ endat> $ conlen-$ listlen/5 or intval ($ endat) <1) {$ j ++; $ listat [$ j] = $ conlen; break ;} else {$ j ++; $ listat [$ j] = $ endat; $ lookat = $ endat + $ listlen ;}// print page $ pagenum = $ j; // total page size $ page = intval ($ c_page); if (emptyempty ($ page) or $ page <1 or $ page> $ pagenum) $ page = 1; if ($ pagenum> 1) for ($ I = 1; $ I <$ pagenum + 1; $ I ++) {echo "{$ I}";} echo" "; $ Stag = $ page-1; $ startb = $ listat [$ stag]; if ($ startb> 0) // remove the first line feed $ startb = $ startb + 1; $ cont = substr ($ content, $ startb, $ listat [$ page]-$ startb); echo" Article content: "; If ($ page> 1) echo" [Next page] "; echo $ cont;?> |