国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > PHP > 正文

php通用翻頁(yè)類,支持上一頁(yè)和下一頁(yè)

2024-05-04 23:06:57
字體:
供稿:網(wǎng)友
  1. function fPageCount($TotalResult,$numPerPage,$Page){ 
  2.     $NaviLength='10' ; //顯示數(shù)量 
  3.     $showMorePageGo_Type_=0; //跳轉(zhuǎn)樣式 
  4.     $int_showNumberLink_='十'
  5.     $nonLinkColor_="#999999";  
  6.     $toF_="<font face=webdings title='首頁(yè)'>9</font>" ; 
  7.     $toP10_=" <font face=webdings title='上十頁(yè)'>7</font>"
  8.     $toP1_=" <font face=webdings title='上一頁(yè)'>3</font>"
  9.     $toN1_=" <font face=webdings title='下一頁(yè)'>4</font>"
  10.     $toN10_=" <font face=webdings title='下十頁(yè)'>8</font>";  
  11.     $toL_="<font face=webdings title='最后一頁(yè)'>:</font>";  
  12.     $page_index = ""
  13.  
  14.     $tpagecount = ceil($TotalResult/$numPerPage); 
  15. $nowCoolPage=ceil($Page/$NaviLength); 
  16.     $toPage_ = $_SERVER['QUERY_STRING']; 
  17.     if ( $toPage_ == '' ) { 
  18.        $toPage_ = "?page=";  
  19.     }else { 
  20.        $toPage_ = preg_replace("/&?page=d+/"'', $toPage_); 
  21.        $toPage_ = "?".$toPage_."&page="
  22.     } 
  23.       
  24. if($nowCoolPage == 1){ 
  25.         $page_index.="<font color=".$nonLinkColor_." title='首頁(yè)'>".$toF_."</font> "
  26.         $page_index.="<font color=".$nonLinkColor_." title='上".$int_showNumberLink_."頁(yè)'>".$toP10_."</font> "
  27.     }else
  28.         $preRow =  $Page-$NaviLength; 
  29.   $page_index.="<a href=".$toPage_."1 title='首頁(yè)'>".$toF_."</a> "
  30.   $page_index.="<a href=".$toPage_.$preRow." title='上".$int_showNumberLink_."頁(yè)'>".$toP10_."</a> "
  31.     }  
  32.     $upRow   = $Page-1; 
  33.     $downRow = $Page+1; 
  34.     if ($upRow>0){ 
  35.        $page_index.="<a href=".$toPage_.$upRow." title='上一頁(yè)'>".$toP1_."</a> "
  36.     }else
  37.        $page_index.="<font color=".$nonLinkColor_." title='上一頁(yè)'>".$toP1_."</font> "
  38.     }  
  39.       
  40. for($i=1;$i<=$NaviLength;$i++){ 
  41.          $nowPage=($nowCoolPage-1)*$NaviLength+$i; 
  42.          if($nowPage!=$Page){ 
  43.              if($nowPage<=$tpagecount){ 
  44.                  $page_index.="  <a href=".$toPage_.$nowPage.">" .$nowPage. "</a> "
  45.              }else
  46.                  break
  47.              } 
  48.          }else
  49.              if($tpagecount != 1){ 
  50.                 $page_index.="<b>".$nowPage."</b>"
  51.              } 
  52.          } 
  53.       } 
  54.      if ($downRow <= $tpagecount){ 
  55.          $page_index.="<a href=".$toPage_.$downRow." title='下一頁(yè)'>".$toN1_."</a> "
  56.      }else
  57.          $page_index.="<font color=".$nonLinkColor_." title='下一頁(yè)'>".$toN1_."</font> "
  58.      } 
  59.      if($nowCoolPage == $tpagecount){ 
  60.          $page_index.=" <font color=".$nonLinkColor_." title='下".$int_showNumberLink_."頁(yè)'>".$toN10_."</font> "
  61.          $page_index.="<font color=".$nonLinkColor_." title='尾頁(yè)'>".$toL_."</font>"
  62.      }else
  63.          $nextRow = $Page+$NaviLength; 
  64.          $theEndRow = $tpagecount; 
  65.          $page_index.=" <a href=".$toPage_.$nextRow." title='下".$int_showNumberLink_."頁(yè)'>".$toN10_."</a> "
  66.          $page_index.="<a href=".$toPage_.$theEndRow." title='尾頁(yè)'>".$toL_."</a>"
  67.      } 
  68.     if ($showMorePageGo_Type_ ==1){ 
  69.       $Show_Page_i = $Page + 1 ; 
  70.     if ($Show_Page_i>$tpagecount) $Show_Page_i = 1;  
  71.     $page_index.="  跳轉(zhuǎn)<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"
  72.        }else
  73.        $page_index.=" 跳轉(zhuǎn):<select name='select' size='1' style='font-size: 12px' onchange='javascript:window.location.href=this.options[this.selectedIndex].value'>";  
  74.      for($i=1;$i<=$tpagecount;$i++){ 
  75.      if($Page==$i){ 
  76.         $selected=" selected"
  77.      }else
  78.         $selected=""
  79.         } 
  80.         $page_index.=" <option value=".$toPage_.$i;  
  81.         $page_index.=$selected." style='color:#FF0000'";  
  82.         $page_index.=">第".$i."頁(yè)</option>"
  83.      }//開源代碼Vevb.com 
  84.         $page_index.="</select>"
  85.    } 
  86.         $page_index.=$p_.$sp2_."  每頁(yè)<b>".$numPerPage."</b>個(gè)記錄,現(xiàn)在是:<b><span class='tx'>".$sp2_.$Page."</span>/".$tpagecount."</b>頁(yè),共<b><span id='recordcount'>".$sp2_.$TotalResult."</span></b>個(gè)記錄。";  
  87.     return $page_index;  

 

例子:<?php echo fPageCount($TotalResult,$numPerPage,$page)?> $TotalResult 代表總數(shù) $numPerPage 每頁(yè)顯示數(shù)量 $page 頁(yè)碼.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿合奇县| 平乐县| 和林格尔县| 岗巴县| 正定县| 闽清县| 开远市| 东兰县| 介休市| 东兰县| 雅江县| 南部县| 雅江县| 大化| 尼勒克县| 峡江县| 文成县| 泰州市| 介休市| 岳阳市| 明水县| 习水县| 和顺县| 南陵县| 博爱县| 洛南县| 清徐县| 衡阳市| 若羌县| 闵行区| 南京市| 龙胜| 西昌市| 景泰县| 江北区| 赞皇县| 惠安县| 曲靖市| 穆棱市| 五莲县| 炉霍县|