我有这样的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');
}
我想做一个分页,每页显示 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 ) )