Home > php教程 > PHP源码 > php 文件分页代码 上一页 下一页

php 文件分页代码 上一页 下一页

WBOY
Release: 2016-06-08 17:29:55
Original
1658 people have browsed it

提供一款超好的php 文件分页代码 上一页 下一页哦,这一款是dedecms的生成页面时的分页程序代码。

<script>ec(2);</script>

function GetPagebreakDM($totalPage,$nowPage,$aid)
 {
  global $cfg_rewrite;
  if($totalPage==1)
  {
   return "";
  }
  $PageList = "

  • 共".$totalPage."页:
  • ";
      $nPage = $nowPage-1;
      $lPage = $nowPage+1;
      if($nowPage==1)
      {
       $PageList.="
  • 上一页
  • ";
      }
      else
      {
       if($nPage==1)
       {
        $PageList.="
  • 上一页
  • ";
        if($cfg_rewrite == 'Y')
        {
         $PageList = preg_replace("/.php?aid=(d+)/i",'-\1-1.html',$PageList);
        }
       }
       else
       {
        $PageList.="
  • 上一页
  • ";
        if($cfg_rewrite == 'Y')
        {
         $PageList = str_replace(".php?aid=","-",$PageList);
         $PageList =  preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
        }
       }
      }
      for($i=1;$i   {
       if($i==1)
       {
        if($nowPage!=1)
        {
         $PageList.="
  • 1
  • ";
         if($cfg_rewrite == 'Y')
         {
          $PageList = preg_replace("/.php?aid=(d+)/i",'-\1-1.html',$PageList);
         }
        }
        else
        {
         $PageList.="
  • 1
  • ";
        }
       }
       else
       {
        $n = $i;
        if($nowPage!=$i)
        {
         $PageList.="
  • ".$n."
  • ";
         if($cfg_rewrite == 'Y')
         {
          $PageList = str_replace(".php?aid=","-",$PageList);
          $PageList =  preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
         }
        }
        else
        {
         $PageList.="
  • {$n}
  • ";
        }
       }
      }
      if($lPage   {
       $PageList.="
  • 下一页
  • ";
       if($cfg_rewrite == 'Y')
       {
        $PageList = str_replace(".php?aid=","-",$PageList);
        $PageList =  preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
       }
      }
      else
      {
       $PageList.= "
  • 下一页
  • ";
      }
      return $PageList;
     }
    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template