Postingan lainnya
Error pagination di codeigniter selalu mulai dari angka akhir
Controller
public function siswa($nisn)
{
$config['base_url'] = base_url().'view/payment/siswa/'.$nisn.'/index';
$config['total_rows'] = count($this->pm->hitung($nisn));
$config['per_page'] = 6;
$this->pagination->initialize($config);
$data['page'] = $this->uri->segment(6);
$data['data_siswa'] = $this->pm->ambil_data($nisn,$config["per_page"], $data['page']);
$data['nisn'] = $nisn;
$data['pagination'] = $this->pagination->create_links();
$this->load->view('payment', $data);
}
Model:
public function ambil_data($nisn,$limit,$start)
{
$this->db->select('*');
$this->db->from('siswa');
//join LEFT by default
$this->db->join('pembayaran', 'pembayaran.id_siswa=siswa.nisn');
$this->db->join('tipe_pembayaran', 'tipe_pembayaran.id_tipe_pembayaran=pembayaran.tipe_pembayaran');
$this->db->where('siswa.nisn = '.$nisn);
$this->db->order_by('tipe_pembayaran','ASEC');
$this->db->limit($limit,$start);
$query = $this->db->get();
if($query->num_rows()>0)
{
foreach ($query->result() as $data) {
$hasil[] = $data;
}
return $hasil;
}else{
return FALSE;
}
}
public function hitung($nisn)
{
return $this->db->get_where('pembayaran', array('id_siswa' => $nisn))->result();
}
pagination selalu mulai dari angka terakhir.
0
1 Jawaban:
Hmm.. Sepertinya typo gan dibagian order_by. Harusnya ASC bkn ASEC ^^
0
Tanggapan
harus ditambah index dulu baru ke number 1 .