PHP simple implementation of the Digital paging function example, php digital paging example
The example in this article describes PHP's simple implementation of the Digital paging function. We will share this with you for your reference. The details are as follows:
<? Phpheader ('content-Type: text/html; charset = UTF-8 '); // page $ page =$ _ GET ['page']; $ allcount = 100; $ page_size = 10; $ page_show = 5; $ page_count = ceil ($ allcount/$ page_size); if ($ page <= 1 | $ page = '') $ page = 1; if ($ page >=$ page_count) $ page = $ page_count; $ pre_page = ($ page = 1 )? 1: $ page-1; $ next_page = ($ page = $ page_count )? $ Page_count: $ page + 1; $ pagenav. = "$ page/$ page_count page $ allcount records"; $ pagenav. = "<a href = '? Page = 1 '> homepage </a> "; $ pagenav. =" <a href = '? Page = $ pre_page '> previous page </a> "; // start of the current display $ page_show_start = (ceil ($ page/$ page_show)-1) * $ page_show; // display pagination $ page_show_str = ''; if ($ page_show> $ page_count) {$ page_show = $ page_count;} for ($ j = 1; $ j <= $ page_show; $ j ++) {$ page_show_now = $ page_show_start + $ j; if ($ page = $ page_show_now) {$ page_show_str. = "<a href = '? Page = $ page_show_now '> <strong> $ page_show_now </strong> </a> ";}else {$ page_show_str. =" <a href = '? Page = $ page_show_now '> $ page_show_now </a> ";}}$ pagenav. = $ page_show_str; $ pagenav. =" <a href = '? Page = $ next_page '> next page </a> "; $ pagenav. =" <a href = '? Page = $ page_count '> last page </a> "; echo' <div class =" page "> '. $ pagenav.' </div> ';?>
Shows the running effect: