0
votes

So I have a page that lists sales leads, this page has a filter form that users submit to filter the list so that it only displays data they choose (as filter criteria), it also has pagination, whenever I use the pagination (as in click on one of the links) and then use the filter, the filter doesn't work, I feel like the problem resides either in the base_url config of the pagination or the uri_segment, as when I post the filter data it is supposed to call a function (filter) which obviously changes the last uri segment from 'list' to 'filter', which happens fine when I don't use pagination, but when I use it and then use the filter it just appends 'filter' to the end, so I end up with 'lists/filter' which isn't right, how can I solve this? :s I've tried removing/changing the uri_segment, is there anyway I can modify the base_url variable of the pagination config to allow it to work? Also when I click on any link that isn't the first page, the number of results displays in my uri, will this affect anything?

Relevant code: Controller:

public function lists($offset = 0) { 
        $this->load->library('pagination');
        $limit = 13;
        $this->load->model('listsalemod'); //load the model that contains the database functionality.
        $lead = $this->listsalemod->listlead($limit, $offset); //load the function that lists leads and pass it to a variable
        $cli = $this->listsalemod->listcli(); //load the function that lists clents and pass it to a variable
        $data = array(); //create an array
        $data['lead'] = $lead['records']; //pass lead data to array
        $data['cli'] = $cli; //pass client data to array 
        $config['base_url'] = site_url('list_sales/lists');
        $config['total_rows'] = $lead['count'];
        $config['per_page'] = 13;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $this->load->library('pagination');
        $data['pagination'] = $this->pagination->create_links();
        $this->load->view('list_sales', $data); //load the view and pass in the data.

View:

<body>   
        <div id="container">
        <form method="post" action="filter">
            BFstaff <input type=text name="staff">
            date:   <input type=text name="date">
            Client  <input type=text name="client">
            <input type="submit" value="submit">
        </form>
        <table id="table">
         <tr>
         <th>short description</th>
         <th>Client</th>
         <th>Created</th>
         <th>view</th>
        <div id="pagination">
        <?php
        echo $pagination;
        ?>

Thank you in advance.

1

1 Answers

0
votes

So I figured it out, basically I am posting my form to 'filter' when I should be posting it to '/my_controller/filter' so that it doesn't just append the method to the url that pagination creates, it now rewrites it from the controller segment.