0
進行分頁這是片斷的控制器,無法通過記錄
function email($start = 0) {
$result = $this -> admintools -> get_email_errors();
if ($result) {
$data['email'] = $result;
}
$data['header'] = $this -> load -> view('includes/header', '', true);
$data['footer'] = $this -> load -> view('includes/footer', $data, true);
$data['menu_system_errors'] = $this -> load -> view('includes/menu_system_errors', $data, true);
//$config['total_rows'] = $this -> db -> query($query);
$config['base_url'] = '/admin/email';
$config['total_rows'] = 1000;
$config['per_page'] = 10;
$config['use_page_numbers'] = TRUE;
for ($i = $start; $i < $start + $config['per_page']; $i++) {
if (isset($data_paging[$i])) {
$data['email']= $data_paging[$i];
}
}
$this -> pagination -> initialize($config);
$this -> load -> view('/admin/email', $data);
}
,這是視圖,
<?=$header
?>
<?=$menu_system_errors
?>
<style>
.alpha-link {
font-size: 22px;
}
</style>
<h1>System Errors EMail</h1>
<table>
<thead>
<tr>
<th>Marketer ID</th>
<th></th>
<th>IP </th>
<th>Received Date</th>
<th>From Domain</th>
<th>Subject</th>
</tr>
</thead>
<? foreach ($systemerrors_email as $systemerror) {
?>
<tr>
<td><?=$systemerror->marketerID
?></td>
<td><?=$systemerror->ip
?></td>
<td></td>
<td><?=$systemerror->received
?></td>
<td><?=$systemerror->fromDomain
?></td>
<td><?=$systemerror->subject
?></td>
</tr>
<? }?>
</table>
<?echo $this -> pagination -> create_links();?>
的問題是它創建的分頁鏈接,但顯示出相同記錄,只有10行,但不是全部。有什麼問題嗎?
我通過查詢使用SELECT和JOIN得到記錄。
通常你在數據庫級別進行分頁,所以你有沒有取的記錄然而,許多不計其數,扔掉一切,但你要顯示的X-每頁。 – 2012-04-02 18:11:49
您應該在mySQL查詢中包含LIMIT子句並使用偏移量功能。 – 2012-04-02 18:17:49