Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter分页第3页链接被禁用_Codeigniter_Pagination - Fatal编程技术网

Codeigniter分页第3页链接被禁用

Codeigniter分页第3页链接被禁用,codeigniter,pagination,Codeigniter,Pagination,这是我的控制器: 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

这是我的控制器:

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);
}
}
如果我只有少于或等于10篇文章2页,则分页工作正常,但如果我有第三个分页链接,则第三个链接将不可排序,并且不是锚定标记。 我在我的另一个页面中使用了相同的分页,它工作正常,但这一个导致了这个问题

这里是分页页面图片的链接。此处突出显示的页面为3,而活动页面仍为1,因此第3页不可用

这是我的另一个实现,我不能用这个分页实现,但这就是我想要的:这里当前页面是第一个,总共有13个项目,每个页面有5个项目


从另一个角度来看,total_rows有问题,它给出了从db中选择的行数而不是total count如果使用任何where子句,最好使用count_all或count_all_result,只需更改它即可

from
$config['total_rows'] = $this->db->get('comment_article')->num_rows();

to 
$config['total_rows'] = $this->db->get('comment_article')->count_all();
在其他服务器上部署项目时,还有一个更改将帮助您

from
$config['base_url'] = 'http://localhost/ci/CodeIgniter_2.1.3/index.php/comment/article/'.$id;

to
$config['base_url'] = base_url('comment/article/'.$id); // it will automatically add default base_url
最重要的是,您必须添加$config['uri_segment'],您必须知道默认情况下哪个段是页码3

$config['uri_segment'] = 3;

查看CI站点上的分页文档

试试$config['first_url']=localhost/CI/CodeIgniter_2.1.3/index.php/comment/article/$id;还可以尝试启用输出探查器和/或ci日志来检查happening@Badaboooooom从哪里可以启用输出探查器和ci日志?$this->output->enable_profilertrue//将此放置在需要视图/模型/控制器的任何位置。。samelogs可以从config/config.php搜索log_tresholdI,我想是这样的。这是第三个url段,但我想要第四个。它现在正在工作。
$config['uri_segment'] = 3;