PHP经典分页导航函数

PHP经典分页导航函数
可自己修改成jsp的分页类似javaeye


PHP版演示地址:
http://php.115000.com.cn/news/html/5/

http://news.115000.com.cn/main_article_list.php?nid=5

http://home.kangju.com.cn/index.php?action=houselist&houseclassid=1&menutab=tab02


PHP经典分页导航函数源码: 复制PHP内容到剪贴板
PHP代码:
#*********************************************************
#文件名称: function.php
#功能描述: 新闻添加修改处理模块
#程序制作:留印(adleyliu)
#联系qq  :14339095
#联系邮箱:[[email protected]][email protected][/email]
#官方网站: http://www.115000.com.cn
#copyright (c) 2007-2008 115000.com.cn all rights reserved.
#最后更新:     2007-11-20
#*********************************************************


#*********************************************************
#分页函数
#*********************************************************
function yl_list_page($pageurl,$rsnum,$pages,$pagecount,$pagesize){
#url
#总记录
#总页数
#当前页码
#每页显示数
   //$pageurl='?';
   $pcount = $pages;
   $page_info = '<div class=pagenum>';
   $page_info .= '<div class=num>';
   if (($pcount > 1) && ($pcount == $pagecount) ){
       $page_info .= '<a href = '.$pageurl.'page='.intval($pagecount-1).'>上一页</a>';
   }elseif (($pagecount != 1) && ($pcount != $pagecount)){
      $page_info .= '<a href = '.$pageurl.'page='.intval($pagecount-1).'>上一页</a>';
   }
      $page_info .= '<a href = '.$pageurl.'page=1>页首</a>';
   if ($pagecount > 4){
     $page_info .= '<a href = '.$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 .= '<span class=normal>'.$n.'</span>';
     }else{
        $page_info .= '<a href = '.$pageurl.'page='.$n.'>['.$n.']</a>';
     }
      }
   }
   if ($pagecount+2 < $pcount){
       $page_info .= '<span class=dot>...</span><a href='.$pageurl.'page='.$pcount.'>['.$pcount.']</a>';
   }
       $page_info .= '<a href = '.$pageurl.'page='.$pcount.'>页尾</a>';
   if (($pagecount == 1) && ($pcount != $pagecount) && ($pcount != 0)){
       $page_info .= '<a href = '.$pageurl.'page='.intval($pagecount + 1).'>下一页</a>';
   }else if (($pagecount != 1) && ($pcount != $pagecount)){
       $page_info .= '<a href = '.$pageurl.'page='.intval($pagecount + 1).'>下一页</a>';
   }
       $page_info .= '</div></div>';
   $page_info .= '<div class=pagenum>';
   $page_info .= '<div class=num><span class=normal> 共:'.$rsnum .'条/'.$pcount.'页 每页/'.$pagesize.'条</span></div>';
   $page_info .= ' <div class=num>';
   //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 .= '</div>';
   $page_info .= '</div>';
      return $page_info;
}





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;
}



jsp页面结合spring 的page类
public class javaEyePage {
/**
* @param pageUrl
* @param rsnum 总记录
* @param pages 总页数
* @param pagecount 当前页码
* @param pagesize 每页显示数
* css javaeyepage.css
* @return
*/
public String getPageList(String pageurl,int rsnum,int pages,int pagecount,int pagesize){
int pcount = pages;
String pageInfo = "";
int endpage = 0;
pageInfo += "<div class=pagenum>";
pageInfo += "<div class=num>";

if ((pcount > 1) && (pcount == pagecount) ){
       pageInfo += "<a href = "+pageurl+"page="+(pagecount-1)+">上一页</a>";
   }else if ((pagecount != 1) && (pcount != pagecount)){
      pageInfo += "<a href = "+pageurl+"page="+(pagecount-1)+">上一页</a>";
   }
      pageInfo += "<a href = "+pageurl+"page=1>页首</a>";
   if (pagecount > 4){
     pageInfo += "<a href = "+pageurl+"page=1>[1]</a><span class=dot>...</span>";
   }
   if (pcount > pagecount+2){
       endpage = pagecount+2;
   }else{
     endpage = pcount;
   }
   for (int n = (pagecount-2); n <= endpage; n++){
      if (!(n < 1)){
         if (n == pagecount){
         pageInfo += "<span class=normal>"+n+"</span>";
     }else{
        pageInfo += "<a href = "+pageurl+"page="+n+">["+n+"]</a>";
     }
      }
   }
   if (pagecount+2 < pcount){
       pageInfo += "<span class=dot>...</span><a href="+pageurl+"page="+pcount+">["+pcount+"]</a>";
   }
       pageInfo += "<a href = "+pageurl+"page="+pcount+">页尾</a>";
   if ((pagecount == 1) && (pcount != pagecount) && (pcount != 0)){
       pageInfo += "<a href = "+pageurl+"page="+pagecount + 1+">下一页</a>";
   }else if ((pagecount != 1) && (pcount != pagecount)){
       pageInfo += "<a href = "+pageurl+"page="+(pagecount + 1)+">下一页</a>";
   }
   pageInfo += "</div></div>";
   pageInfo += "<div class=pagenum>";
   pageInfo += "<div class=num><span class=normal> 共:"+rsnum +"条/"+pcount+"页 每页/"+pagesize+"条</span></div>";
   pageInfo += " <div class=num>";
   //echo '<form name=page action='.$pageurl.'>';
   pageInfo += " 转到";
   pageInfo += "<input type=text name=page value=\"1\" class=login_left style=\"width:28px;height:18px;\">";
   pageInfo += "页<input type=submit name=submit3 class=login_submit style=\"width:28px;height:18px;padding-top:1px;\" onclick=document.myform.action.value=\"go\"> ";
   //echo '</form>';
   pageInfo += "</div>";
   pageInfo += "</div>";
      return pageInfo;
}

}

你可能感兴趣的:(spring,PHP,jsp,css,qq)