Home > php教程 > php手册 > body text

精美漂亮的php分页类代码

WBOY
Release: 2016-06-06 20:32:02
Original
1207 people have browsed it

非常精美的一款php分页类,可以直接应用到分页系统上,是一款mysql数据库分页必备的一个工具,只需要将类文件和分页CSS样式嵌入即可实现精美分页。

这是一款简单,方便,功能齐全的分页类,可以根据自己的需要更改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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!