网站建设知识

Zebra_Pagination 2.0 发布 PHP 分页类

发布: | 发布时间:2013-02-06 22:51

 

Zebra_Pagination 2.0 不再支持 PHP 4 ,要求至少 PHP 5 版本,修复了 URL 中包含 HTML 内容的 bug,上一页和下一页显示关联的标签等。

Zebra_Pagination 是一个通用的 PHP 类,用来根据记录数和每页显示数自动生成分页链接。

示例代码:

<?php
// let's paginate data from an array...
$countries = array(
    // array of countries
);

// how many records should be displayed on a page?
$records_per_page = 10;

// include the pagination class
require 'path/to/Zebra_Pagination.php';

// instantiate the pagination object
$pagination = new Zebra_Pagination();

// the number of total records is the number of records in the array
$pagination->records(count($countries));

// records per page
$pagination->records_per_page($records_per_page);

// here's the magick: we need to display *only* the records for the current page
$countries = array_slice(
    $countries,
    (($pagination->get_page() - 1) * $records_per_page),
    $records_per_page
);

?>

<table>
    <tr><th>Country</th></tr>
    <?php foreach ($countries as $index => $country):?>
    <tr<?php echo $index % 2 ? ' class="even"' : '')?>>
        <td><?php echo $country?></td>
    </tr>
    <?php endforeach?>
</table>
<?php
// render the pagination links
$pagination->render();

?>

下载地址:
万唯科技作为唐山地区专业的网络服务提供商,已经为上百家企事业单位提供了网站建设网站制作、网站改版、域名注册、网站空间租用等服务,优质的服务得到了广大客户的一致认可,如果您有网站建设、网站改版、网站维护等方面的需求,请致电:0315-6723159,我们会根据您所从事的行业领域和网站类型,在最短的时间内请我们的营销顾问与您预约后上门拜访您,直接面谈交流为您解答所有的网站建设疑问。

网站建设知识

网站建设| 案例展示| 网站推广| 服务项目| 关于我们| 联系我们| 建站知识| 唐山网络公司博客
  • 热线电话: 0315-6723159
  • 传真:0315-6723159 邮箱:449324@qq.com
  • 公司地址:丰南区瑞景街18号金融中心3层
  • 乘车路线:乘坐80、88、89路车到“欣荣街市场(银丰市场)”站,即到。北方电子对面。
万唯科技最值得信赖的品牌-万唯网络品牌网站建设专家
Copyright © 2012-2013 0315www.com. 万唯科技 版权所有  ICP备案号:冀ICP备12021829号