Note that there are some explanatory texts on larger screens.

plurals
  1. POcodeigniter pagination with join table
    primarykey
    data
    text
    <p>I'm trying to put pagination into my CodeIgniter project. I've followed the instructions carefully, I did manage to join the table and show them in my "mahasiswa_view", but when I try to combine it with pagination, it says error : </p> <p><img src="https://s24.postimg.org/xixjl8vit/error_pagination.jpg" alt="check on this error pic"></p> <p>Here's my controller code = "home" : </p> <pre><code>class Home extends CI_Controller { function __construct() { parent::__construct(); $this-&gt;load-&gt;model('modelku'); } function index($offset = NULL) { //pagination $limit = 3; if(!is_null($offset)) { $offset = $this-&gt;uri-&gt;segment(3); } $this-&gt;load-&gt;library('pagination'); $config['uri_segment'] = 3; $config['base_url'] = site_url('home/index'); $config['total_rows'] = $this-&gt;modelku-&gt;total_record_mahasiswa(); $config['per_page'] = $limit; $config['num_links'] = 5; $config['first_link'] = 'First'; $config['last_link'] = 'Last'; $this-&gt;pagination-&gt;initialize($config); //$data['mahasiswa']=$this-&gt;modelku-&gt;get_mahasiswa_all(); $data['mahasiswa'] = $this-&gt;modelku-&gt;get_mahasiswa_all($limit,$offset); $this-&gt;load-&gt;view('mahasiswa_view',$data); } </code></pre> <p>And here's my model code = "modelku" :</p> <pre><code>if(!defined('BASEPATH')) exit('No direct script access allowed'); class Modelku extends CI_Model { //pagination function total_record_mahasiswa() { return $this-&gt;db-&gt;count_all('tb_mahasiswa','tb_prodi'); //return $this-&gt;db-&gt;count_all('tb_mahasiswa'); } function get_mahasiswa_all($limit,$offset) { $this-&gt;db-&gt;select('tb_mahasiswa.nim, tb_mahasiswa.nama, tb_mahasiswa.tanggal_lahir, tb_mahasiswa.jenis_kelamin, tb_mahasiswa.alamat, tb_mahasiswa.propinsi, tb_mahasiswa.telepon, tb_mahasiswa.email, tb_mahasiswa.photo, tb_mahasiswa.prodi, tb_prodi.namaprodi'); $this-&gt;db-&gt;from('tb_mahasiswa'); $this-&gt;db-&gt;join('tb_prodi','tb_mahasiswa.prodi=tb_prodi.kode'); //$query = $this-&gt;db-&gt;get(); $this-&gt;db-&gt;order_by('nim','ASC'); //$query = $this-&gt;db-&gt;get('tb_mahasiswa','tb_prodi',$limit, $offset); $query = $this-&gt;db-&gt;get($limit, $offset); return $query-&gt;result(); } </code></pre> <p>And the last one, my view = 'mahasiswa_view' :</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;PHP Framework&lt;/title&gt; &lt;link rel="stylesheet" href="&lt;?php echo base_url() ?&gt;asset/css/style.css"/&gt; &lt;/head&gt; &lt;body&gt; &lt;h3&gt;Selamat Datang di Form Mahasiswa&lt;/h3&gt; &lt;table width="80%" border="1" &gt; &lt;tr style="background-color:blue; color:white;"&gt; &lt;td&gt; No. &lt;/td&gt; &lt;td&gt; NIM &lt;/td&gt; &lt;td&gt; Nama &lt;/td&gt; &lt;td&gt; Tanggal Lahir &lt;/td&gt; &lt;td&gt; Jenis Kelamin &lt;/td&gt; &lt;td width="20%"&gt; Alamat &lt;/td&gt; &lt;td&gt; Telepon &lt;/td&gt; &lt;td&gt; Email &lt;/td&gt; &lt;td&gt; Prodi &lt;/td&gt; &lt;td&gt; Photo &lt;/td&gt; &lt;/tr&gt; &lt;?php if(isset($msg_error)) { echo '&lt;div style="color:red;"&gt;' . $msg_error.'&lt;/div&gt;'; } ?&gt; &lt;?php echo anchor('home/login','Login'); $no=1; foreach ($mahasiswa as $row) { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $no; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;nim . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;nama . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;tanggal_lahir . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;jenis_kelamin . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;alamat . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;telepon . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;email . ' '; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;namaprodi . ' ';?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;photo . ' &lt;/br&gt;';?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php $no++; } ?&gt; &amp;nbsp &lt;form action="&lt;?php print site_url();?&gt;/home/cari" method=POST&gt; &lt;input type=text name=cari&gt; &lt;input type=submit value="Cari"&gt; &lt;/form&gt; &lt;/table&gt; &lt;?php echo "&lt;br /&gt;&lt;div&gt;" .$this-&gt;pagination-&gt;create_links() ."&lt;/div&gt;"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm still new to CodeIgniter so any help would be appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload