Welcome Guest, Not a member yet? Register   Sign In
url routing issue
#1

[eluser]learnq[/eluser]
Hi,
I have url like

http://127.0.0.1/blog/urltest/7987

Code:
class Blog extends Controller {    
...
...

  function urltest($i)
  {
  echo $i;
}


}

I can get the value 7987.



now when I route

Code:
$route['utest/:num'] = "blog/urltest/$i";

and

http://127.0.0.1/utest/7987

I donot get 7987 .





Again if I have a url like

http://127.0.0.1/blog/urltest/7987/theprodname

how do I get 7987 and theprodname


What is wrong ? Please help.
Thanks.
#2

[eluser]Natebot[/eluser]
Code:
$route['utest/(:num)'] = 'blog/urltest/$1';

I think you use parentheses around the wildcard to designate the matched content to be passed to the function.
#3

[eluser]Hazlitt[/eluser]
The $this->uri->segment(n) function can help you get the different segments of the url.

This article may help:

http://ellislab.com/codeigniter/user-gui...s/uri.html
#4

[eluser]learnq[/eluser]
Hi,
Thanks for the replies .I have fixed the problem.




Theme © iAndrew 2016 - Forum software by © MyBB