Zebra_Pagination 2.0 发布,PHP 分页类
2013-02-01 17:31
375 查看
Zebra_Pagination 2.0 不再支持 PHP 4 ,要求至少 PHP 5 版本,修复了 URL 中包含 HTML 内容的 bug,上一页和下一页显示关联的标签等。
Zebra_Pagination 是一个通用的 PHP 类,用来根据记录数和每页显示数自动生成分页链接。
示例代码:
view sourceprint?
Zebra_Pagination 是一个通用的 PHP 类,用来根据记录数和每页显示数自动生成分页链接。
示例代码:
view sourceprint?
01 | <?php |
02 | // let's paginate data from an array... |
03 | $countries = array ( |
04 | // array of countries |
05 | ); |
06 |
07 | // how many records should be displayed on a page? |
08 | $records_per_page =10; |
09 |
10 | // include the pagination class |
11 | require 'path/to/Zebra_Pagination.php' ; |
12 |
13 | // instantiate the pagination object |
14 | $pagination = new Zebra_Pagination(); |
15 |
16 | // the number of total records is the number of records in the array |
17 | $pagination ->records( count ( $countries )); |
18 |
19 | // records per page |
20 | $pagination ->records_per_page( $records_per_page ); |
21 |
22 | // here's the magick:we need to display *only* the records for the current page |
23 | $countries = array_slice ( |
24 | $countries , |
25 | (( $pagination ->get_page() - 1) * $records_per_page ), |
26 | $records_per_page |
27 | ); |
28 |
29 | ?> |
30 |
31 | <table> |
32 |
33 | <tr><th>Country</th></tr> |
34 |
35 | <?php foreach ( $countries as $index => $country ):?> |
36 |
37 | <tr<?php echo $index % 2 ? ' class="even"' : '' )?>> |
38 | <td><?php echo $country ?></td> |
39 | </tr> |
40 |
41 | <?php endforeach ?> |
42 |
43 | </table> |
44 |
45 | <?php |
46 |
47 | // render the pagination links |
48 | $pagination ->render(); |
49 |
50 | ?> |
相关文章推荐
- PHP超强分页类2.0发布
- 超强PHP分页类2.0发布,支持自定义风格,默认4种显示模式 _2
- PHP6.0 即将发布 更强大的本地化及Web 2.0支持
- PHP6.0 即将发布 更强大的本地化及Web 2.0支持
- 超强分页类2.0发布
- ci 分页类 伪静态错误的情况,需要修改\system\libraries\Pagination.php
- PHP分页类2.0[转]
- 专业就是力量,php论坛新动力,动网php2.0++正式发布
- 超强分页类2.0发布,支持自定义风格,默认4种显示模式
- PHP 6 即将发布 更强大的本地化及Web 2.0支持
- 超强分页类2.0发布,支持自定义风格,默认4种显示模式
- 【PHP分页】Zebra_Pagination - 通用分页类
- PHP超强分页类2.0使用心得
- Delphi for PHP 2.0发布了~~
- 发布一个php分页类
- 【软件周刊】Bootstrap 将不再支持 IE 9;Swoole 2.0 正式版发布,协程特性支持 PHP 7
- 超强、实用、简单的PHP分页类2.0
- PHP Zend Framework 2.0 正式版发布
- 整合Oracle 10g、Apache 2.0、PHP 5
- kohana 3.2版本可用的分页类pagination