[eluser]bcarter[/eluser]
Ok here goes
Controller
Code:
function results($query_id = 0, $offset = 0)
{
//Load helpers, profiler, models etc
$this->load->model('enquiries/Search_model');
$this->load->library('pagination');
//Get the drop down options
$data['course_list'] = $this->Search_model->get_courses();
$data['status_list'] = $this->Search_model->get_enquiries_status();
$data['source_list'] = $this->Search_model->get_enquiries_source();
$data['referer_list'] = $this->Search_model->get_enquiries_referer();
//Start to build the page
$this->load->view('includes/head', $data);
$this->load->view('enquiries/includes/header', $data);
$this->my_functions->load_query($query_id);
$query_array = array(
'search' => $this->input->get('search'),
'type' => $this->input->get('type'),
'interest' => $this->input->get('interest'),
'source' => $this->input->get('source'),
'referer' => $this->input->get('referer'),
'status' => $this->input->get('status'),
);
$data['values'] = $query_array;
//How many results do we want to show per page?
$config['per_page'] = 10;
//Make the query
$data['query_id'] = $query_id;
$results = $this->Search_model->search($query_array, $config['per_page'], $offset);
//Thank you query, here's the data
$data['results'] = $results['rows'];
$data['num_results'] = $results['num_rows'];
//For the pagination
$this->load->library('pagination');
$data['total_rows'] = $data['num_results'];
$config['base_url'] = base_url() . "index.php/enquiries/enquiry/results/$query_id";
$config['total_rows'] = $data['num_results'];
$config['num_links'] = 9;
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
//Create the pagination and get it loaded
$this->pagination->initialize($config);
//Load the views
$this->load->view('enquiries/search_results_view', $data);
$this->load->view('includes/footer');
}
View
Code:
Search results display here...
<?php echo $this->pagination->create_links() ?>