Reputation: 23
This is snippet for the controller,
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);
}
and this is the view,
<?=$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();?>
The problem is it creates the pagination links but displays the same record, like only 10 rows but not whole of them. Is there any problem?
I am getting the records through a query using SELECT and JOIN.
Upvotes: 0
Views: 70
Reputation: 11588
You need to know what config keys do what in order to get pagination to work.
$config['total_rows']
defines the total amount of rows you want shown;
$config['per_page']
defines how many you want shown per page.
The reason you're seeing 10 results shown is because your per_page
value is set to 10, if you want more, change it to the value you want. Also, shouldn't your $start
variable in your controller be set to $this->uri->segment(3)
? Since it relies on the the URL parameter, you're not allowing your loop to start from the next portion of rows -- you're basically forcing it to display the first ten queries. If you set this variable so that it relies on something dynamic, you'd be able to get other data.
Upvotes: 1