扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
class page{ /** * 分页 * @param int $total 总数 * @param int $num 每页显示数 * @param int $curpage 当前页码 * @param string $mpurl URL * @param string $ajax ajax * @param int $maxpages 最大 * @param int $page 显示分页数 * @param string $autogoto * @param string $simple * @return string */ public function multiPage($total, $num, $curpage, $mpurl, $ajaxFun = '', $maxpages = 0, $page = 10, $autogoto = FALSE, $simple = FALSE) { $shownum = $showkbd = TRUE; $lang['prev'] = '‹‹'; $lang['next'] = '››'; $ajaxtarget = ''; $multipage = ''; $mpurl = current(explode('&page', $mpurl)); $mpurl .= strpos($mpurl, '?') ? '&' : '?'; if ($ajaxFun) { $mpurl; } $realpages = 1; $curpage = $curpage ? $curpage : 1; if($total > $num) { $offset = 2; $realpages = @ceil($total / $num); $pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages; if($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if($from < 1) { $to = $curpage + 1 - $from; $from = 1; if($to - $from < $page) { $to = $page; } } elseif($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } $multipage = ($curpage - $offset > 1 && $pages > $page ? 'multiPageUrl($mpurl.'page=1', $ajaxFun) .' class="first"'.$ajaxtarget.'>1 ...' : ''). ($curpage > 1 && !$simple ? 'multiPageUrl($mpurl.'page='.($curpage - 1), $ajaxFun) .' class="prev"'.$ajaxtarget.'>'.$lang['prev'].'' : ''); for($i = $from; $i <= $to; $i++) { $multipage .= $i == $curpage ? ''.$i.'' : ' multiPageUrl($mpurl.'page='.$i, $ajaxFun) . $ajaxtarget.'>'.$i.' '; } $multipage .= ($to < $pages ? ' multiPageUrl($mpurl.'page='.$pages, $ajaxFun) .' class="last"'.$ajaxtarget.'>... '.$realpages.' ' : ''). ($curpage < $pages && !$simple ? ' multiPageUrl($mpurl.'page='.($curpage + 1), $ajaxFun) .'class="next"'.$ajaxtarget.'>'.$lang['next'].' ' : ''). ($showkbd && !$simple && $pages > $page && !$ajaxtarget && $autogoto ? '' : ''); $multipage = $multipage ? ''.'Total '.$total.' '.$multipage.'' : ''; } $maxpage = $realpages; return $multipage; } public function multiPageUrl($s, $fun){ if ($fun) { $str = 'href = "javascript:;" onclick="'.$fun.'(\''.$s.'\')" '; }else{ $str = 'href = "'.$s.'" '; } return $str; } public function css(){ $s = '.pages {height: 50px; padding-top: 20px; clear: both;} .pages A,.pages strong{ background-color: #0A4B99; margin-left: 10px; border: 1px solid #818181; color: #FFFFFF; display: block; float: left; height: 20px; padding: 5px 13px 2px 12px; width: auto;} .pages A:HOVER{background-color: #72B3FF} .pages strong{background-color: #fff; color: #000;} .pages span{float: left; padding: 5px 0 2px 12px; color:#0A4B99;font-weight: bold; font-size: 15px;} .pages strong{border: 1px solid #0A4B99;} .next, .prev{font-size: 25px; line-height: 11px;color: yellow !important;}'; return $s; } }
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流