Welcome Guest, Not a member yet? Register   Sign In
Combining a Search Function with Pagination
#1

[eluser]Brokenegg.wb[/eluser]
Hello All,
I'm creating a simple e-commerce site, one of the functions that i;m currently hung up on is the search function, I've got the search itself down, but I'm running into an issue of sorting the returned results using the pagination feature. Heres what i have so far:

the Controller:
Code:
function search()
    {
        $this->load->library('pagination');
        $this->load->library('table');
        
        $data['records'] = $this->site_db_upload->get_records_store_search();
        
        
        $this->load->view(', $data);
    }

Site_db_upload (the modle):
Code:
function get_records_store_search()
    {
    
        
        $keywords = $this->input->post('keyword');
        $where = "(`item_name`  LIKE '%$keywords%' OR  `attribution`  LIKE '%$keywords%' OR  `material`  LIKE '%$keywords%' OR  `age`  LIKE '%$keywords%' OR  `description`  LIKE '%$keywords%')";
        $query = $this->db->get_where('items', $where);
        $config['base_url'] = 'http://www.rareintaglio.com/index.php/store';
        $config['total_rows'] =  $this->db->get_where('items', $where)->num_rows();
        $config['per_page'] = 9;
        $config['num_links'] = 7;
        $config['full_tag_open'] = '<div id="pagination">';
        $config['full_tag_close'] = '</div>';
        return $query->result();
    }

I'm sure it's smacking me in the face, but i just can't see the solution for the life of me, any tips are very welcome.
Thanks,
Watson
#2

[eluser]LuckyFella73[/eluser]
Hej Watson,

the problem is that after submitting the form your post values
are available only at the next page. What you need is to carry on
the keywords (and maybe some sorting keys).

Have a look at this post - it may help you solving the problem:
http://ellislab.com/forums/viewthread/145990/




Theme © iAndrew 2016 - Forum software by © MyBB