简体   繁体   English

将值传递给codeigniter分页

[英]passing value to codeigniter pagination

i am using codeigniter pagination. 我正在使用codeigniter分页。 i want to pass a value through url to the controller by which i can fetch data based on condition 我想通过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);
}

how can i pass "?type=something" through url without affecting the offset value 如何在不影响偏移值的情况下通过url传递“?type = something”

change your base_url config as follows 按如下方式更改base_url配置

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

it will not affect your offset. 它不会影响你的偏移量。 Others stuff will automatically be appended after it 其他东西将自动附加在其后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM