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

[eluser]the_unforgiven[/eluser]
I sused it out:

Model:
Code:
public function record_count() {
        return $this->db->count_all("wc_program");
    }

    public function fetch_all($limit, $start, $term) {

     $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->db->limit($limit, $start);
        $query = $this->db->get("wc_program");

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
   }

Controller:
Code:
public function program_search()
{
  $config = array();
        $config["base_url"] = base_url().'/site/program_search/';
        $config["total_rows"] = $this->wc_search->record_count();
        $config["per_page"] = 15;
        $config["uri_segment"] = 3;
        $config['num_links'] = 1;
        $config['full_tag_open'] = '<div class="pagination pagination-small"><ul>';
  $config['full_tag_close'] = '</ul></div>';
  $config['first_link'] = false;
  $config['last_link'] = false;
  $config['first_tag_open'] = '<li>';
  $config['first_tag_close'] = '</li>';
  $config['prev_link'] = '&laquo;';
  $config['prev_tag_open'] = '<li class="prev">';
  $config['prev_tag_close'] = '</li>';
  $config['next_link'] = '&raquo;';
  $config['next_tag_open'] = '<li>';
  $config['next_tag_close'] = '</li>';
  $config['last_tag_open'] = '<li>';
  $config['last_tag_close'] = '</li>';
  $config['cur_tag_open'] =  '<li class="active"><a href="#">';
  $config['cur_tag_close'] = '</a></li>';
  $config['num_tag_open'] = '<li class="page">';
  $config['num_tag_close'] = '</li>';

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

        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data["results"] = $this->wc_search->fetch_all($config["per_page"], $page, $this->input->post('term'));
        $data["links"] = $this->pagination->create_links();

        $this->front->buffer('content', 'site/program_search_results', $data);
  $this->front->render();
}

Works a treat and with Bootstrap too for pagination, but thanks for your advise this prompted me to change it all and re-write it.


Messages In This Thread
Search with $term and pagination - by El Forum - 05-29-2013, 12:11 PM
Search with $term and pagination - by El Forum - 05-29-2013, 05:32 PM
Search with $term and pagination - by El Forum - 05-30-2013, 01:58 AM
Search with $term and pagination - by El Forum - 05-30-2013, 04:13 AM
Search with $term and pagination - by El Forum - 05-30-2013, 04:16 AM
Search with $term and pagination - by El Forum - 05-30-2013, 04:17 AM
Search with $term and pagination - by El Forum - 05-30-2013, 04:24 AM
Search with $term and pagination - by El Forum - 05-30-2013, 04:27 AM
Search with $term and pagination - by El Forum - 05-30-2013, 09:37 AM
Search with $term and pagination - by El Forum - 05-30-2013, 10:15 AM
Search with $term and pagination - by El Forum - 05-30-2013, 10:17 AM
Search with $term and pagination - by El Forum - 06-06-2013, 08:31 AM
Search with $term and pagination - by El Forum - 06-06-2013, 04:55 PM
Search with $term and pagination - by El Forum - 06-07-2013, 01:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB