Home > Backend Development > PHP Tutorial > 精美漂亮的php分页类代码_PHP

精美漂亮的php分页类代码_PHP

WBOY
Release: 2016-06-01 12:07:55
Original
1036 people have browsed it

    这是一款简单,方便,功能齐全的分页类,可以根据自己的需要更改CSS样式文件以实现分页颜色的控制,利用php分页类,可以省去自己很多时间,只需要在分页的地方嵌入即可,下面看下使用方法:

    1,在head里包含pager.css
复制代码 代码如下:
   

    2,在分页处进行类的实例化:

复制代码 代码如下:
     include "pager.class.php";   
  $CurrentPage=isset($_GET['page'])?$_GET['page']:1;   
  //die($CurrentPage);   
     $myPage=new pager(1300,intval($CurrentPage));   
      $pageStr= $myPage->GetPagerContent();   
  //echo $pageStr;   
     $myPage=new pager(90,intval($CurrentPage));    
     $pageStr= $myPage->GetPagerContent();   
  echo $pageStr;   
    ?>  

  3,读取mysql数据库和分页计算文件需要自己写出来。例如:

    $info=mysql_query("select * from member order by id desc limit $offset,$info_num");  这样才能调到 mysql 数据库和当前页码等。

    下面是一共包含的三个文件:(1) index.php:调用分页类,显示分页 (2) pager.class.php:php分页类 (3)pager.css:css样式美化文件

    (1) index.php:

复制代码 代码如下:

   
   
----分页演示-----   
   
   
   
         include "pager.class.php";   
     $CurrentPage=isset($_GET['page'])?$_GET['page']:1;   
     //die($CurrentPage);   
     $myPage=new pager(1300,intval($CurrentPage));   
      $pageStr= $myPage->GetPagerContent();   
     //echo $pageStr;   
     $myPage=new pager(90,intval($CurrentPage));    
     $pageStr= $myPage->GetPagerContent();   
     echo $pageStr;   
    ?>   
   
Related labels:
php
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template