php通用翻页类,支持上一页和下一页
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-09 17:00:44 浏览: 评论:0
- function fPageCount($TotalResult,$numPerPage,$Page){
- $NaviLength='10' ; //显示数量
- $showMorePageGo_Type_=0; //跳转样式
- $int_showNumberLink_='十';
- $nonLinkColor_="#999999";
- $toF_="<font face=webdings title='首页'>9</font>" ;
- $toP10_=" <font face=webdings title='上十页'>7</font>";
- $toP1_=" <font face=webdings title='上一页'>3</font>";
- $toN1_=" <font face=webdings title='下一页'>4</font>";
- $toN10_=" <font face=webdings title='下十页'>8</font>";
- $toL_="<font face=webdings title='最后一页'>:</font>";
- $page_index = "";
- $tpagecount = ceil($TotalResult/$numPerPage);
- $nowCoolPage=ceil($Page/$NaviLength);
- $toPage_ = $_SERVER['QUERY_STRING'];
- if ( $toPage_ == '' ) {
- $toPage_ = "?page=";
- }else {
- $toPage_ = preg_replace("/&?page=d+/", '', $toPage_);
- $toPage_ = "?".$toPage_."&page=";
- }
- if($nowCoolPage == 1){
- $page_index.="<font color=".$nonLinkColor_." title='首页'>".$toF_."</font> ";
- $page_index.="<font color=".$nonLinkColor_." title='上".$int_showNumberLink_."页'>".$toP10_."</font> ";
- }else{
- $preRow = $Page-$NaviLength;
- $page_index.="<a href=".$toPage_."1 title='首页'>".$toF_."</a> ";
- $page_index.="<a href=".$toPage_.$preRow." title='上".$int_showNumberLink_."页'>".$toP10_."</a> ";
- }
- $upRow = $Page-1;
- $downRow = $Page+1;
- if ($upRow>0){
- $page_index.="<a href=".$toPage_.$upRow." title='上一页'>".$toP1_."</a> ";
- }else{
- $page_index.="<font color=".$nonLinkColor_." title='上一页'>".$toP1_."</font> ";
- }
- for($i=1;$i<=$NaviLength;$i++){
- $nowPage=($nowCoolPage-1)*$NaviLength+$i;
- if($nowPage!=$Page){
- if($nowPage<=$tpagecount){
- $page_index.=" <a href=".$toPage_.$nowPage.">" .$nowPage. "</a> ";
- }else{
- break;
- }
- }else{
- if($tpagecount != 1){
- $page_index.="<b>".$nowPage."</b>";
- }
- }
- }
- if ($downRow <= $tpagecount){
- $page_index.="<a href=".$toPage_.$downRow." title='下一页'>".$toN1_."</a> ";
- }else{
- $page_index.="<font color=".$nonLinkColor_." title='下一页'>".$toN1_."</font> ";
- }
- if($nowCoolPage == $tpagecount){
- $page_index.=" <font color=".$nonLinkColor_." title='下".$int_showNumberLink_."页'>".$toN10_."</font> ";
- $page_index.="<font color=".$nonLinkColor_." title='尾页'>".$toL_."</font>";
- }else{
- $nextRow = $Page+$NaviLength;
- $theEndRow = $tpagecount;
- $page_index.=" <a href=".$toPage_.$nextRow." title='下".$int_showNumberLink_."页'>".$toN10_."</a> ";
- $page_index.="<a href=".$toPage_.$theEndRow." title='尾页'>".$toL_."</a>";
- }
- if ($showMorePageGo_Type_ ==1){
- $Show_Page_i = $Page + 1 ;
- if ($Show_Page_i>$tpagecount) $Show_Page_i = 1;
- $page_index.=" 跳转<input type='text' id='skip' value='' onkeyup='this.value=this.value.replace(/[^d]+/,'')' style='width:40px'/> <input type='button' value='确定' class='btn' onclick='location.href='?page='+$('skip').value+'".$toPage_."';'/>n";
- }else{
- $page_index.=" 跳转:<select name='select' size='1' style='font-size: 12px' onchange='javascript:window.location.href=this.options[this.selectedIndex].value'>";
- for($i=1;$i<=$tpagecount;$i++){
- if($Page==$i){
- $selected=" selected";
- }else{
- $selected="";
- }
- $page_index.=" <option value=".$toPage_.$i;
- $page_index.=$selected." style='color:#FF0000'";
- $page_index.=">第".$i."页</option>";
- }//开源代码phpfensi.com
- $page_index.="</select>";
- }
- $page_index.=$p_.$sp2_." 每页<b>".$numPerPage."</b>个记录,现在是:<b><span class='tx'>".$sp2_.$Page."</span>/".$tpagecount."</b>页,共<b><span id='recordcount'>".$sp2_.$TotalResult."</span></b>个记录。";
- return $page_index;
- }
例子:<?php echo fPageCount($TotalResult,$numPerPage,$page)?> $TotalResult 代表总数 $numPerPage 每页显示数量 $page 页码.
Tags: php通用翻页 php上一页
- 上一篇:php利用模板分页程序
- 下一篇:php与Redis分页程序代码
相关文章
- ·php实现网页上一页下一页翻页过程详解(2021-11-29)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)