2013-11-04 42 views
0

我有一個分頁腳本,我的笨做,這是我的腳本笨分頁問題與查詢字符串

/*---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值;

回答