This article mainly introduces PHP simple implementation of the digital paging function, combined with examples of PHP digital paging related mathematical operations and string manipulation related skills, the need for friends can refer to the following
Specific as follows:
<?phpheader (' content-type:text/html; Charset=utf-8 ');//Pagination $page=$_get[' page ']; $allcount = +; $page _size =10;$ Page_show =5; $page _count = Ceil ($allcount/$page _size); if ($page <= 1 | | $page = = ") $page = 1;if ($page >= $page _coun T) $page = $page _count; $pre _page = ($page = = 1)? 1: $page-1; $next _page= ($page = = $page _count)? $page _count: $page + 1; $pagenav. = "$page/$page _count page Total $allcount records"; $pagenav. = "<a href= '? page=1 ' > Home </ A> "; $pagenav. =" <a href= '? page= $pre _page ' > Previous </a> ";//start of current display $page_show_start = (ceil ($page/$page _ Show)-1) * $page _show;//Show Paging $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 </a>"; $pagenav. = "<a href="? Page= $page _ Count ' > End </a> "; Echo ' <p class=" page "> '. $pagenav. ' </p> ';? >
The effect is as follows:
Summary: The above is the entire content of this article, I hope to be able to help you learn.