本文整理汇总了PHP中Pager::getPagerData方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::getPagerData方法的具体用法?PHP Pager::getPagerData怎么用?PHP Pager::getPagerData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::getPagerData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: min
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass();
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
$page = $_GET['page'];
$limit = 7;
$result = mysql_query("select count(*) from news");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// use pager values to fetch data
$is_published = "1";
$query = "select * from news WHERE is_published = '{$is_published}' order by id desc limit {$offset}, {$limit}";
$result = mysql_query($query);
//check if the id is set
if ($result == "") {
?>
<p> No News </p>
<?php
} else {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
示例2: showPaging
function showPaging($query, $res_set, $PageURL)
{
global $db;
$page = $_REQUEST['page'];
$limit = 20;
$sql = $query;
$totalcom = count($res_set);
$total = $totalcom;
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
$sql .= " limit {$offset},{$limit}";
$res_page = $db->select_data($sql);
$total_com = count($res_page);
Pager::getPaging_pagenum($PageURL, $page, $pager->numPages, $pager->limit);
return $res_page;
}