How to pass parameter via URL? |
[eluser]Sinclair[/eluser]
Hi, I need to pass a parameter in the second segment of an URL in the index function of the controller. My model function is this: Code: function getAnunZone($pzone) { This is not working. What I'am doing wrong? Best Regards.
[eluser]CroNiX[/eluser]
I dont understand the comma in your sql or what you are trying to do with the 2nd url segment. I would have written it like: Code: <?php
[eluser]Sinclair[/eluser]
Hi, I'am trying to pass the value for the parameter "$pzone" in the URL. Like this: http://www.example.com/ads/HERE_I_PASS_THE_PARAMETER HERE_I_PASS_THE_PARAMETER = $pzone This is possible? Best Regards,
[eluser]CroNiX[/eluser]
Code: <?php I just gave pzone a default value of $this->uri->segment(2). $pzone_data = $this->getAnunZone(); //will get pzone data where id_zone = 2nd parameter of uri $pzone_data = $this->getAnunZone(5); //will get pzone data where id_zone = 5
[eluser]CroNiX[/eluser]
Another thought...you are using segment 2. Segment 2 is usually the function/method of your controller and segment 3+ is used for variables (unless you've done something in your routes). www.mysite.com/ads/view/4 Controller = ads Function = view parameter = 4 (uri->segment(3))
[eluser]Sinclair[/eluser]
Thanks for your reply, but I can't get working. It works if I have this: - Model: Code: function getAnunciosZona($pzona) { - Controller: Code: function index() { But if I have this, when I call the second segment, gives me an error. I call the parameter like this: http://www.example.com/anuncios/SP - Model: Code: function getAnunciosZona($pzona) { - Controller: Code: function index() { What I'am doing wrong? Best Regards,
[eluser]Sinclair[/eluser]
[quote author="CroNiX" date="1255487132"]Another thought...you are using segment 2. Segment 2 is usually the function/method of your controller and segment 3+ is used for variables (unless you've done something in your routes). www.mysite.com/ads/view/4 Controller = ads Function = view parameter = 4 (uri->segment(3))[/quote] I don't have see this post. I think that is the problem. I'am trying to passo to the second segment...
[eluser]Sinclair[/eluser]
Problem Solved. I can't pass parameters in the second segment. |
Welcome Guest, Not a member yet? Register Sign In |