這裏是我的控制器:笨分頁第3頁的鏈接成爲殘疾
class Comment extends CI_Controller {
function article() {
$this->load->library('pagination');
$this->load->model('comment_m');
$id=$this->uri->segment(3);
$config['base_url'] = 'http://localhost/ci/CodeIgniter_2.1.3/index.php/comment/article/'.$id;
$config['total_rows'] = $this->db->get('comment_article')->num_rows();
$config['per_page'] = 5;
$config['num_links'] = 5;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
echo $this->uri->segment(4);
$data['c_review'] = $this->comment_m->getarticle($id, $config['per_page'], $this->uri->segment(4));
$this->load->view('comment_v', $data);
}
}
這裏是我的模型:
class Comment_m extends CI_Model{
function getarticle($id,$limit,$start) {
$this->db->select('name, content');
$this->db->from('comment_article');
$this->db->where('article_id', $id);
$this->db->limit($limit, $start);
$q = $this->db->get();
if($q->num_rows() > 0) {
foreach ($q->result() as $c_review) {
$data[] = $c_review;
}
return $data;
}
}
}
分頁工作正常,如果我有小於或等於10篇( 2頁),但如果我有第三個分頁鏈接,那麼第三個鏈接變得不可循環,而不是一個錨標籤。 我在我的其他頁面中使用了相同的分頁,它工作正常,但是這是導致此問題的原因。
以下是分頁頁面圖片的鏈接。這裏突出顯示的頁面是3,而活動頁面仍然是1,所以第三頁面是不可靠的。
這是我的其他實現這我不能夠實現這個分頁,但是這就是我想要的:這裏的當前頁是第1次和總的13個項目都是有每頁5個項目。
This is link to the desired implementation
試** $配置[ 'first_url'] =「localhost/ci/CodeIgniter_2.1.3/index.php/comment/article /".$ id; ** – sbaaaang
也嘗試啓用輸出分析器和/或ci日誌來檢查發生了什麼 – sbaaaang
@Badaboooooom from where我們可以啓用輸出分析器和ci日誌嗎? – user1953363