【发布时间】:2017-11-10 21:24:25
【问题描述】:
我的分页功能的以下代码如下:-
public function news()
{
$this->load->library('pagination');
$config = array();
$config["base_url"] = base_url() . "index.php/welcome/news";
$this->load->model('news_model');
$total_row = $this->news_model->record_count();
$config["total_rows"] = $total_row;
$config["per_page"] = 1;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['page_query_string'] = TRUE;
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
$this->pagination->initialize($config);
if($this->uri->segment(3)){
$page = ($this->uri->segment(3)) ;
}
else{
$page = 1;
} //echo $config["per_page"].'/'.$page; exit();
$this->load->model('news_model');
$data["results"] = $this->news_model->fetch_data($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$data["links"] = explode(' ',$str_links );
$this->load->model('news_model');
$data['lt_news'] = $this->news_model->get_lt_newsletter();
$data['rm_news'] = $this->news_model->get_rm_newsletter();
$this->load->view('newsletter/newsletter',$data);
}
从上面的代码中,url浏览器显示如下:-
http://localhost/ins/index.php/welcome/news?per_page=2
我很困惑如何将其更改为如下所示:
http://localhost/ins/index.php/welcome/news/2
有没有办法做到这一点..?我是 codeigniter 分页的新手,所以我不知道是否有必要将 url 参数更改为像上面那样..?
【问题讨论】:
标签: php codeigniter pagination