Welcome Guest, Not a member yet? Register   Sign In
Search with $term and pagination
#11

[eluser]the_unforgiven[/eluser]
I have watched that video and the whole thing does work but what i said here http://ellislab.com/forums/viewreply/1054087/ about it just carrying on through pagination is not what i need
#12

[eluser]the_unforgiven[/eluser]
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?
#13

[eluser]jairoh_[/eluser]
Code:
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]

        $this->load->library('pagination');

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

        $this->db->where('JobRef',$this->input->post('term'));
        $this->db->or_where('WorkType',$this->input->post('term'));
        $this->db->or_where('Parish',$this->input->post('term'));
        $this->db->or_where('Location',$this->input->post('term'));

        $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>';

        $this->pagination->initialize($config);    

         //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->render();
    }
    else
    {
        $this->front->set('title', 'Program Search');
        $this->front->buffer('content', 'site/program_search');
        $this->front->render();
    }
}


Code:
public function search($term, [u]$of, $limit[ul] )  //pass the offset and limit
        {
    $data = array();
    $this->default_select();
    $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);

    $this->default_order_by();
    //$this->db->limit(15);
    $q = $this->db->get('wc_program');
        if ($q->num_rows() > 0)
        {
            foreach ($q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
    $q->free_result();
    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
#14

[eluser]the_unforgiven[/eluser]
Ok i'll try that, thanks Smile




Theme © iAndrew 2016 - Forum software by © MyBB