我使用Codeigniter..and我是新來這個。我想要做的是在我的代碼中使用分頁,但問題是分頁鏈接沒有顯示在底部。分頁codeigniter
控制器:
function index()
{
$this->load->library('pagination');
$config['base_url'] = 'Rfetch1_controller/index/';
$total = $this->db->count_all('info');
$per_page = 4;
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['list'] = $this->Rfetch1_model->get_s($config['per_page'],$this->uri->segment(3));
if ($data['list']!== null){
$this->load->view('Rfetch1_view', $data);
}
else {
$this->load->view('noresult');
}
}
型號:
function get_s($num, $offset) {
$this->db->select ('subject, id, problem,image'); // field name
$sql = $this->db->get('info',$num, $offset); // table name
if ($sql->num_rows() >0) {
foreach($sql->result() as $row) {
$data[$row->id] = $row->subject;
}
return $data;
}
else {
return null;
}
}
的觀點:
foreach($list as $id => $title):?>
<?echo anchor('Rfetch1_controller/get_by_id/'. $id, $title);?>
<?php endforeach;?>
<?php echo $this->pagination->create_links(); ?>
爲什麼分頁鏈接無法顯示請幫
我有worte關於Codeigniter分頁的教程。 https://www.cloudways.com/blog/pagination-in-codeigniter/。看看並提出建議 –