将值传递给codeigniter分页

时间:2016-07-20 11:54:21

标签: php codeigniter url pagination get

我正在使用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"通过网址而不影响偏移值

1 个答案:

答案 0 :(得分:0)

按如下方式更改base_url配置

$config['base_url'] = site_url('MarketPostingCenter/index?type='.$type);

它不会影响你的偏移量。其他东西将自动附加在

之后