私はvkategorimaterial
このようなビューを持っています
<table border="1">
<tr>
<td colspan="4">Tampilkan<?php
echo form_open('c_kategorimaterial/cari');
echo nbs();$intext=array('name' => 'cari', 'class' => 'GUI');
echo form_input($intext);
echo nbs(); $inbutton=array('value' => 'Cari', 'class' => 'button');
echo form_submit($inbutton);
echo form_close();
?></td>
</tr>
<tr>
<td colspan="4"><a href="<?php echo base_url(); ?>index.php/c_kategorimaterial/tambah"><img class ="create" src="<?php echo base_url();?>img/create.png"></a></td>
</tr>
<tr>
<td>Nomor</td>
<td>Kode Kategori Material / Jasa</td>
<td>Nama Material / Jasa</td>
<td>Perintah</td>
</tr>
<?php if ( !empty($rows) )
{
$no = 1;
foreach ($rows as $row) { ?>
<tr id="row">
<td><?php echo $no;?></td>
<td><?php echo $row->Kode_Kategori_Material_Jasa;?></td>
<td><?php echo $row->Nama_Material_Jasa;?></td>
<td> <a href="<?php echo site_url('c_kategorimaterial/ubah/'.$row->Kode_Kategori_Material_Jasa.'/'.$row->Nama_Material_Jasa);?>"><img class="perintah" src="<?php echo base_url(); ?>img/update.png"></a><a href="<?php echo site_url('c_kategorimaterial/hapus/'.$row->Kode_Kategori_Material_Jasa);?>" onclick="return confirm('akan dihapus, anda yakin ?');"><img class="perintah" src="<?php echo base_url(); ?>img/delete.png"></a></td>
</tr>
<?php
$no++;
}
}
else { ?>
<tr id="row">
<td colspan="6" align="center">Tabel Kosong</td>
</tr>
<?php
}
?>
</table>
<?php echo $this->pagination->create_links(); ?>
c_kategorimaterial
次に、ここに名前が付けられたコントローラーを作成しましindex
た
function index()
{
$query = $this->m_kategorimaterial->get();
$config['base_url'] = base_url().'index.php/c_kategorimaterial/index/';
$config['total_rows'] = $query->num_rows();
$config['per_page'] = 5;
$this->pagination->initialize($config);
$data['rows'] = $query->result();
$data['title'] = 'QB Kategori Material';
$this->load->view('menu',$data);
$this->load->view('v/vkategorimaterial');
}
1ページあたり5行を表示するページネーションを作りたいです。そして、ここにのモデルがありますm_kategorimaterial->get
$this->db->order_by('Kode_Kategori_Material_Jasa','DESC');
$query = $this->db->get('ms_kategori_material',5);
return $query;
ページネーションが表示されないのはなぜですか? これが結果ですprint_r($data['rows']);
Array ( [0] => stdClass Object ( [Kode_Kategori_Material_Jasa] => KKMJ006 [Nama_Material_Jasa] => Biji ) [1] => stdClass Object ( [Kode_Kategori_Material_Jasa] => KKMJ004 [Nama_Material_Jasa] => Teneh ) [2] => stdClass Object ( [Kode_Kategori_Material_Jasa] => KKMJ001 [Nama_Material_Jasa] => Air ) )