Home > Backend Development > PHP Tutorial > Page paging function_PHP tutorial

Page paging function_PHP tutorial

WBOY
Release: 2016-07-20 11:09:15
Original
1544 people have browsed it

Provide an example classification function, friends in need can refer to it.

//page paging function
$page = $_get["page"];
function page($rows,$page_size){
global $page,$select_from,$select_limit,$pagenav;
$page_count = ceil($rows/$page_size);
if($page <= 1 || $page == '') $page = 1;
if($page >= $page_count) $page = $page_count;
$select_limit = $page_size;
$select_from = ($page - 1) * $page_size.',';
$pre_page = ($page == 1)? 1 : $page - 1;
$next_page= ($page == $page_count)? $page_count : $page + 1 ;
$pagenav . = "$page/$page_count page with $rows records";
$pagenav .= "Homepage ";
$pagenav .= "Previous page ";
$pagenav .= "After One page ";
$pagenav .= "Last page";
$pagenav.=" Jump to