本文整理匯總了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;
}