标签:
/** * 分页效果显示 */ function getPagestr($url, $totalNum, $showNum, $page) { $totalPage = ceil($totalNum / $showNum); $page = intval($_GET[‘p‘]); $page = ($page < 1)? 1 : $page; $start = ($page - 1) * $showNum; $prev = $page - 1; $prev = max($prev, 1); $next = $page + 1; $next = min($next, $totalPage); $str .= ‘‘; $str .= ‘<a href="‘.$url.‘&p=1" style="cursor:pointer">首页</a> ‘; for($i=4; $i>0; $i--) { $page_i = $page - $i; if($page_i < 1) continue; $str .= ‘ <a href="‘.$url.‘&p=‘.$page_i.‘" style="cursor:pointer">‘.$page_i.‘</a> ‘; } $str .= ‘ <span class="page-cur">‘.$page.‘</span> ‘; for($i=1; $i<5; $i++) { $page_i = $page + $i; if($page_i > $totalPage) continue; $str .= ‘ <a href="‘.$url.‘&p=‘.$page_i.‘" style="cursor:pointer">‘.$page_i.‘</a> ‘; } $str .= ‘ <a href="‘.$url.‘&p=‘.$totalPage.‘" style="cursor:pointer">尾页</a> ‘; $str .= ‘共返回 ‘.$totalNum.‘ 条数据 ‘; $str .= ‘共 ‘.$totalPage.‘ 页 ‘; return $str; }
标签:
原文地址:http://www.cnblogs.com/dsczs/p/4353746.html