Welcome Guest, Not a member yet? Register   Sign In
Pagination config problem
#1

[eluser]CI_Newb[/eluser]
Trying to get pagination working properly on my search form but having issues getting the total_rows.

I need to get the total_rows from the query rather than from entire database.

Model
Code:
function admin_search($num, $offset)
    {
        $start_date = $this->input->post('startDate');    
        $end_date = $this->input->post('endDate');
        $username = $this->input->post('username');
        
        $dateRange = "submit_date BETWEEN '$start_date' and '$end_date'";
        $this->db->where($dateRange, NULL);
        $this->db->like('username', $username);

        $data = $this->db->get('data', $num, $offset);
        
        if($data->num_rows() > 0) {
            return $data;
            }
    }

Controller
Code:
function admin_results()
    {
        $this->load->library('pagination');
        
         $config['base_url'] = base_url().'/search/admin_results/';
        $config['total_rows'] = $this->db->count_all('data');
        $config['per_page'] = '100';
        $config['num_links'] = 3;
        $config['full_tag_open'] = '<p>';
    $config['full_tag_close'] = '</p>';
    
    $this->pagination->initialize($config);
        
        $data['users'] = $this->menus->agents_menu();
        $data['search'] = $this->search_model->admin_search($config['per_page'],$this->uri->segment(3));
        $this->load->view('content/header');
        $this->load->view('admin/admin_search_view', $data);
        $this->load->view('content/footer');
    }

Displaying in view
Code:
echo $this->pagination->create_links();

How do I get the total number of rows from
Code:
$data['search'] = $this->search_model->admin_search($config['per_page'],$this->uri->segment(3));

To show for
Code:
$config['total_rows'] = $this->db->count_all('data');


Messages In This Thread
Pagination config problem - by El Forum - 11-11-2010, 09:38 PM
Pagination config problem - by El Forum - 11-12-2010, 06:32 AM
Pagination config problem - by El Forum - 11-12-2010, 07:20 AM
Pagination config problem - by El Forum - 11-13-2010, 08:25 PM
Pagination config problem - by El Forum - 11-14-2010, 01:58 AM
Pagination config problem - by El Forum - 11-15-2010, 01:12 AM
Pagination config problem - by El Forum - 11-15-2010, 01:51 AM
Pagination config problem - by El Forum - 11-15-2010, 03:40 AM
Pagination config problem - by El Forum - 11-15-2010, 03:48 AM
Pagination config problem - by El Forum - 11-15-2010, 04:13 AM
Pagination config problem - by El Forum - 11-15-2010, 04:42 AM
Pagination config problem - by El Forum - 11-15-2010, 05:53 AM
Pagination config problem - by El Forum - 11-15-2010, 06:02 AM
Pagination config problem - by El Forum - 11-15-2010, 06:06 AM
Pagination config problem - by El Forum - 11-15-2010, 06:18 AM
Pagination config problem - by El Forum - 11-15-2010, 07:41 AM
Pagination config problem - by El Forum - 11-15-2010, 08:20 AM
Pagination config problem - by El Forum - 11-15-2010, 08:43 AM
Pagination config problem - by El Forum - 11-15-2010, 08:59 AM
Pagination config problem - by El Forum - 11-15-2010, 09:51 AM
Pagination config problem - by El Forum - 11-15-2010, 10:43 AM
Pagination config problem - by El Forum - 11-15-2010, 11:11 AM
Pagination config problem - by El Forum - 11-15-2010, 11:23 AM
Pagination config problem - by El Forum - 11-15-2010, 11:31 AM
Pagination config problem - by El Forum - 11-26-2010, 10:21 PM
Pagination config problem - by El Forum - 11-29-2010, 02:03 AM
Pagination config problem - by El Forum - 11-29-2010, 02:45 AM
Pagination config problem - by El Forum - 11-29-2010, 03:07 AM
Pagination config problem - by El Forum - 11-29-2010, 03:08 AM
Pagination config problem - by El Forum - 11-29-2010, 03:10 AM
Pagination config problem - by El Forum - 11-29-2010, 03:11 AM
Pagination config problem - by El Forum - 11-29-2010, 03:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB