探讨PHP分页导航函数的具体应用
程序员文章站
2022-04-25 13:34:17
...
我们今天为大家介绍的是有关
PHP分页导航函数的代码示例:
- function yl_list_page($pageurl,$rsnum,
$pages,$pagecount,$pagesize){ - //$pageurl='?';
- $pcount = $pages;
- $page_info = '';
- $page_info .= '';
- if (($pcount > 1) && ($pcount == $pagecount) ){
-
$page_info .= '.$pageurl.
'page='.intval($pagecount-1).'>上一页 /a>'; - }elseif (($pagecount != 1) && ($pcount != $pagecount)){
- $page_info .= 'page='.intval($pagecount-1).'>上一页 /a>';
- }
- $page_info .= '.$pageurl.'page=1>页首 /a>';
- if ($pagecount > 4){
- $page_info .= '.$pageurl.'page=1>[1] /a>span class=dot>... /span>';
- }
- if ($pcount > $pagecount+2){
- $endpage = $pagecount+2;
- }else{
- $endpage = $pcount;
- }
- for ($n = ($pagecount-2); $n = $endpage; $n++){
- if (!($n 1)){
- if ($n == intval($pagecount)){
- $page_info .= ''.$n.' /span>';
- }else{
- $page_info .= '.$pageurl.'page='.$n.'>['.$n.'] /a>';
- }
- }
- }
- if ($pagecount+2 $pcount){
- $page_info .= '...page='.$pcount.'>['.$pcount.'] /a>';
- }
- $page_info .= '.$pageurl.'page='.$pcount.'>页尾 /a>';
- if (($pagecount == 1) && ($pcount != $pagecount) && ($pcount != 0)){
- $page_info .= '.$pageurl.'page='.intval($pagecount + 1).'>下一页 /a>';
- }else if (($pagecount != 1) && ($pcount != $pagecount)){
- $page_info .= '.$pageurl.'page='.intval($pagecount + 1).'>下一页 /a>';
- }
- $page_info .= '';
- $page_info .= '';
- $page_info .= ' 共:'.$rsnum .'条/'.$pcount.'页 每页/'.$pagesize.'条 /span>div>';
- $page_info .= ' ';
- //echo ' form name=page action='.$pageurl.'>';
- $page_info .= ' 转到';
- $page_info .= ' input type=text name=page value='1' class=login_left style='width:28px;height:18px;'>';
- $page_info .= '页 input type=submit name=submit3 class=login_submit style='width:28px;height:18px;padding-top:1px;' onclick=document.myform.action.value='go'> ';
- //echo ' /form>';
- $page_info .= '';
- $page_info .= '';
- return $page_info;
- }
PHP分页导航函数的CSS样式:
- /*page*/
- .pagenum {
- clear: both; width: '100%';
- padding-right: 5px;
- padding-left: 0px;
- font-weight: bold;
- padding-bottom: 0px;
- overflow: hidden;
- color: #6396d6;
- padding-top: 0px;
- height: 25px;
- }
- .pagenum .num {
- float: right;
- }
- .pagenum .normal {
- background: #f7fbff;color: #6396d6;
- float: left;
- padding-bottom: 2px;
- margin: 0px 3px 0px 0px;
- padding-top: 3px;
- border-left: #6396d6 1px solid;
- border-right: #6396d6 1px solid;
- padding-right: 5px;
- padding-left: 5px;
- border-top: #6396d6 1px solid;
- border-bottom: #6396d6 1px solid;
- }
- .pagenum .dot {
- float: left;color: #6396d6;
- }
- .pagenum a {
- background: #298ac6;
- color: #fff;
- float: left;
- padding-bottom: 2px;
- margin: 0px 3px 0px 0px;
- padding-top: 3px;
- border-left: #6396d6 1px solid;
- border-right: #6396d6 1px solid;
- padding-right: 5px;
- padding-left: 5px;
- border-top: #6396d6 1px solid;
- border-bottom: #6396d6 1px solid;
- }
- .pagenum a:visited {
- color: #fff;
- }
- .pagenum a:hover {
- background: #f7fbff;color: #6396d6;
- border-left: #6396d6 1px solid;
- border-right: #6396d6 1px solid;
- border-top: #6396d6 1px solid;
- border-bottom: #6396d6 1px solid;
- }
以上就是 PHP分页导航函数的具体实现代码。