3

my current url is http://localhost/ci/test_test/test/12/abc

12 is my id and abc is the value which are to be passed in the function test

now i want that my url would look like this http://localhost/ci/test_test/test/id/12/val/abc function may know that after the id keyword its the id and after the value keyword its the value

public function test($id="",$code=""){ 
        $data['id']=$id;
        $data['code']=$code;
		$this->load->view('welcome_message',$data);
	}

1
  • why do you want to add id and val in url? Any specific reason? Commented May 8, 2015 at 8:04

1 Answer 1

5

In your routes.php , set your url like this :

$route['test_test/test/id/(:num)/val/(:any)'] = "path/to/your_controller/$1/$2";

and your controller :

public function your_controller($id="",$val){
    //...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.