Php codeigniter分页中的索引限制
很抱歉,我希望创建表分页连接两个表 我试图创建它,当我单击“下一步”时,会出现这样的错误 控制器中的我的代码Php codeigniter分页中的索引限制,php,mysql,codeigniter,pagination,Php,Mysql,Codeigniter,Pagination,很抱歉,我希望创建表分页连接两个表 我试图创建它,当我单击“下一步”时,会出现这样的错误 控制器中的我的代码 public function index() { $this->load->model('mymodel'); $this->load->library('pagination'); $config['base_url'] = base_url().'index.php/admin/page/index/'; $config['
public function index()
{
$this->load->model('mymodel');
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/admin/page/index/';
$config['total_rows'] = $this->mymodel->tampil_data()->num_rows();
$config['per_page'] = 10;
$this->pagination->initialize($config);
$data['paging'] =$this->pagination->create_links();
$halaman = $this->uri->segment(3);
$halaman =$halaman==''?0:$halaman;
$data['record'] = $this->mymodel->tampil_data_paging($halaman,$config['per_page']);
$this->template->load('template','view',$data);
}
和我的模型
function tampil_data()
{
$query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
FROM messrequestor as b,messvisitor as kb
WHERE b.idrequestor=kb.idrequestor";
return $this->db->query($query);
}
function tampil_data_paging($halaman,$batas)
{
$query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
FROM messrequestor as b,messvisitor as kb
WHERE b.idrequestor=kb.idrequestor limit $halaman,$batas";
return $this->db->query($query);
}
如何解决
多谢各位
$config['base_url'] = base_url().'index.php/admin/page/index/';
//then you use this
$halaman = $this->uri->segment(3);
$halaman =$halaman==''?0:$halaman;
这是以“索引”的形式检索段,因此将其放在sql中,这就是错误所在。如果实际值在后面,则需要获得另一段,即4
$query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
FROM messrequestor as b,messvisitor as kb
WHERE b.idrequestor=kb.idrequestor limit $halaman,$batas
这是以“索引”的形式检索段,因此将其放在sql中,这就是错误所在。如果实际值在后面,则需要获得另一段,即4
$query= "SELECT b.requestorname,b.checkin,b.checkout,b.company,b.email,b.contactnumber,b.purpose,
kb.name,kb.checkinvisitor,kb.checkoutvisitor,kb.companyvisitor,kb.position,kb.contactnumbervisitor
FROM messrequestor as b,messvisitor as kb
WHERE b.idrequestor=kb.idrequestor limit $halaman,$batas
在这个控制器中,您检索作为“索引”的段,所以这是放在您的sql中的,您需要获取其他段
在这个控制器中,您检索作为“索引”的段,所以这是放在您的sql中的,您需要获取其他段