CodeIgniter Forums
Search with $term and pagination - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Search with $term and pagination (/showthread.php?tid=58277)

Pages: 1 2

Search with $term and pagination - El Forum - 05-30-2013

I have watched that video and the whole thing does work but what i said here about it just carrying on through pagination is not what i need

Search with $term and pagination - El Forum - 06-06-2013

Kinda got this working, but if i do a search and it only displays 6 results the pagination still shows, which obviously the pagination should only show if there's more than 15 results which is the limit per page i have put on, can anyone advise on what im doing wrong?

Search with $term and pagination - El Forum - 06-06-2013

public function program_search( [u]$of[/u] ) //this should have an offset variable for the pagination base url                //to pass
      if ($this->input->post('term')){
        $this->front->set('title', 'Search Results');
       [u] $this->front->set('res' ,  $this->wc_search->search($this->input->post('term')));[/u]


        [u]$config['base_url'] = base_url().'/site/program_search_results/'; [/u]
        //must be $config['base_url'] = your base url to the contoller.'/program_search/';


        $config['total_rows'] = $this->db->count_all_results('wc_program');
        [u]$config['per_page'] = 10;[/u] //this is the limit
        $config['num_links'] = 20;
        $config['full_tag_open'] = '<div id="pagination">';
        $config['full_tag_close'] = '</div>';


         //should be here
         [u]$this->front->set('res' ,  $this->wc_search->search($this->input->post('term'), offset, limit ));[/u]

        $this->front->buffer('content', 'site/program_search_results');
        $this->front->set('title', 'Program Search');
        $this->front->buffer('content', 'site/program_search');

public function search($term, [u]$of, $limit[ul] )  //pass the offset and limit
    $data = array();
    $this->db->like('JobRef', $term);
    $this->db->or_like('Area', $term);
    $this->db->or_like('Parish', $term);
    $this->db->or_like('WorkType', $term);
    $this->db->or_like('Location', $term);

    $q = $this->db->get('wc_program');
        if ($q->num_rows() > 0)
            foreach ($q->result_array() as $row)
                $data[] = $row;
    return $data;
that's pretty much the concept. but i don't know why your query, just try debugging. i don't use active records. i use bindings.

PS: the underlined tag didn't work

Search with $term and pagination - El Forum - 06-07-2013

Ok i'll try that, thanks Smile