Ricky
Ricky

Reputation: 19

URL issue with route setting

$route['allgrant'] = "grant/allgrant";

The above is working fine for the URL: http://localhost/grant/allgrant

But I am getting error with URL http://localhost/grant/allgrant/6

My route setting is below:

$route['allgrant/(:num)'] = "grant/allgrant/$1";

My controller code:

public function allGrant()
{
    $this->load->library('pagination');
    $config = array();
    $config["base_url"] = base_url('allGrant');
    $config['total_rows'] =   $this->db->count_all("grant_data");
    $config['per_page'] = 3;
    $config["uri_segment"] = 2;
    $this->pagination->initialize($config);
    $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
    $data["allGrant"] = $this->grant_model->allGrant($config["per_page"], $page);
        $data["links"] = $this->pagination->create_links();
    $data['mainContent'] = 'viewGrant';
    $this->load->view('include/template',$data);
}

when I load the all grant page it show me the first three result but when I click on the pagination it give error with page not found

Upvotes: 0

Views: 46

Answers (3)

user3232286
user3232286

Reputation:

Try this one add this route in your file

$route['grant/allgrant/(:num)'] = "grant/allgrant/$1";

Upvotes: 1

Atul Jindal
Atul Jindal

Reputation: 976

Settings missing with .htaccess, and it is not able to parse the last parameter in URL

Upvotes: 0

Hassaan
Hassaan

Reputation: 7672

Change from

$route['allgrant/(:num)'] = "grant/allgrant/$1";

To

$route['allgrant/(:any)'] = "grant/allgrant/$1";

Upvotes: 0

Related Questions