Hello

I am build pagination but its give me stuck.

admin_cont Controller Page

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

$config['base_url'] = "http://localhost/Job-portal-CI/admin_cont/search_me";
$config['total_rows'] = $this->db->get("admin_emp_job_description")->num_rows();
$config['per_page'] = 2;
$config['num_links'] = 20;


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

$data['records'] = $this->db->get('admin_emp_job_description',$config['per_page'],$this->uri->segment(3));

$this->load->view('admin_jobseeker/search_lists',$data);

View Page

<?php echo $this-> table-> generate($records); ?>    
<?php echo $this->pagination->create_links(); ?>

Problem

Its give me Link but when click on Next or 2 then given me blank page

Any One can suggest me what can i do for next..

Thank$

can you post your codes from model?

Member Avatar for iamthwee

You have to use the uri segment to do a select start and limit.

Member Avatar for iamthwee

eg The second and third parameters enable you to set a limit and offset clause:

$query = $this->db->get('mytable', 10, 20);

// Produces: SELECT * FROM mytable LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)

RePost In Controller

$config["base_url"] = base_url() . "search_me/";
$config["total_rows"] = $this->admin_jobseeker_model->record_count();
$config["per_page"] = 2;
$config["uri_segment"] = 2;

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

$page = ($this->uri->segment(2))? $this->uri->segment(2) : 0;
$data["results"] = $this->admin_jobseeker_model->get_records($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();

In Model

function record_count()
    {
        return $this->db->count_all("admin_emp_job_description");
    }

function get_records($limit, $start)
    {
        $this->db->limit($limit,$start);
        $query = $this->db->get("admin_emp_job_description");
        $this->output->enable_profiler(TRUE);
        if($query->num_rows() > 0)
        {
            foreach($query->result() as $row){

                    $data[] = $row;
            }
                return $data;
        }
            return false;
    }

In Routes

$route['search_me/(:any)'] = "admin_cont/search_me/$1";

Problem: Pagination URL link not working

Stuff..No One have Solution.

Solved this One.
I just make seprate function rather then index()
so now i Apply in index() and $config["base_url"] = "controller/index"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.