我正在使用codeigniter分页。我想通过url将值传递给控制器,我可以根据条件
获取数据function index($offset) {
$type = $_GET['type'];
$this->load->library('pagination');
$config['base_url'] = base_url().'MarketPostingCenter/index';
$config['per_page'] = 15;
// $config['total_rows'] = 200;
if($type=="Agent"){
$data['market_posts'] = $this->model->getAllMarketPostsOfAgent('market_posting_tbl', $_SESSION['id'],$config['per_page'],$offset);
$config['total_rows'] = $this->model->getAllMarketPostsOfAgentCount('market_posting_tbl', $_SESSION['id']);
}elseif($type=="Underwriter"){
$data['market_posts'] = $this->model->getAllMarketPosts('market_posting_tbl',$_SESSION['id'],$config['per_page'],$offset);
$config['total_rows'] = $this->model->getAllMarketPostsCount('market_posting_tbl', $_SESSION['id']);
}
$this->pagination->initialize($config);
// print_r( $data['market_posts']);
$data['user'] = $this->model->getUser('profile_tbl', $_SESSION['id']);
$data['order'] ="";
$data['states'] = $this->model->getAllStates('states');
$this->load->view('MarketPostingCenter/marketPostingCenter.php',$data);
}
我怎样才能通过"?type = something"通过网址而不影响偏移值
答案 0 :(得分:0)
按如下方式更改base_url
配置
$config['base_url'] = site_url('MarketPostingCenter/index?type='.$type);
它不会影响你的偏移量。其他东西将自动附加在
之后