[eluser]mashary[/eluser]
Controller
Code:
function daftarlist(){
$this->load->library('pagination');
$config['base_url'] = base_url().'anggota/daftarlist/';
$config['total_rows'] = $this->db->count_all('data_pegawai');
$config['per_page'] = $this->config->item('per_page');
$config['first_link'] = 'First';
$config['first_tag_open'] = '<div>';
$config['first_tag_close'] = '</div>';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<div>';
$config['last_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['kiri'] = $this->load->view('pencarian','',true);
$table['data'] = $this->pegawai->daftar($config['per_page'],$this->uri->segment(3));
$data['isi'] = $this->load->view('pegawai/daftar_pegawai',$table,true);
$this->load->view('template',$data);
}
and here is model
Code:
function daftar($banyak='',$mulai=''){
$this->db->select('id,nik,nama,group,alamat');
$this->db->from('data_pegawai');
$this->db->limit($banyak,$mulai);
return $this->db->get();
}
the view code like this
Code:
<table width="100%" border="0" cellpadding="5" class="table">
<tr height="35px">
<th width="12%" align="center">NIK</th>
<th width="57%" align="center">NAMA</th>
<th width="15%" align="center">BASE</th>
<th width="16%" align="center">OPSI</th>
</tr>
<?php
if ($data->num_rows()>0){
$group = $this->config->item('group');
foreach ($data->result() as $nilai ){
?>
<tr align="center">
<td><?=$nilai->nik?></td>
<td align="left"><?=$nilai->nama?></td>
<td><?=$nilai->base?></td>
<td>opsi</td>
</tr>
<?php
}
}else{
?>
<tr>
<td colspan="4" align="center"> Data Kosong</td>
</tr>
<?php
}
?>
</table>
<!-- here is link for pagination, dont miss it-->
<p align="center"><?=$this->pagination->create_links();?></p>
hope these code can help u!!!