我有一个在codeigniter中创建的分页脚本,这是我的脚本
/*---product_pagination----*/
$total_row = $this->autoload_model->get_data_from_table("td_model,td_country","*",
"td_country.country_id = td_model.model_country
AND td_model.model_id > 0
ORDER BY td_model.model_username")->num_rows();
echo $total_row;
$this->load->library('pagination');
//$start_row= $this->uri->segment(3);
$segment_3 = $this->uri->segment(3);
if($segment_3 == '')
{
$start_row = 0;
}
else
$start_row = $_REQUEST['start_row'];
if(isset($_REQUEST['per_page']))
$perpage = $_REQUEST['per_page'];
else
$perpage = 2;
if(trim($start_row) == '')
{
$start_row =0;
}
$config['base_url'] = base_url().'model/show_model/?start_row='.$start_row;
$config['total_rows'] = $total_row;
$config['per_page'] = $perpage;
$config['uri_segment'] = 3;
$config['page_query_string'] = TRUE;
$config['full_tag_open'] = "<div class='pagination'>";
$config['full_tag_close'] = '</div>';
$config['cur_tag_open'] = "<span style='width: 80px; '>";
$config['cur_tag_close'] = '</span>';
$config['first_link'] = '<< First';
$config['first_tag_open'] = "<span style='width: 80px; '>";
$config['first_tag_close'] = '</span>';
$config['last_link'] = 'Last >>';
$config['last_tag_open'] = "<span style='width: 80px; '>";
$config['last_tag_close'] = "</span>";
$config['next_link'] = 'Next >';
$config['next_tag_open'] = "<span style='width: 80px; '>";
$config['next_tag_close'] = '</span>';
$config['prev_link'] = '< Prev';
$config['prev_tag_open'] = "<span style='width: 80px; '>";
$config['prev_tag_close'] = '</span>';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['all_model']=$this->autoload_model->get_data_from_table("td_model,td_country","*",
"td_country.country_id = td_model.model_country
AND td_model.model_id > 0
ORDER BY td_model.model_username")->result_array();
$data['model_list']=$this->autoload_model->get_data_from_table("td_model,td_country","*",
"td_country.country_id = td_model.model_country
AND td_model.model_id > 0
ORDER BY td_model.model_username
LIMIT $start_row, $perpage")->result_array();
/*$this->product_model->products_fragment_by_category($cat_slug,$start_row,$perpage);*/
/*----pagination ends------*/
$this->load->view('header',$data);
$this->load->view('header_lower');
$this->load->view('model_list');
$this->load->view('left_bar');
$this->load->view('footer');
}
问题是我得到了这个网址
http://localhost/ecam/model/show_model/?start_row=0&per_page=2
http://localhost/ecam/model/show_model/?start_row=0&per_page=4
为什么per_page会扩展到2 4 6 ...
似乎start_row值是per_page值;
答案 0 :(得分:1)
请注意,“per_page”是传递的默认查询字符串,但可以使用
进行配置 $config['query_string_segment'] = 'offset';//you change per_page param-name to offset
http://ellislab.com/codeigniter/user-guide/libraries/pagination.html