Get a variable from url |
[eluser]raduenea[/eluser]
I want to get a variable from url and to make a select in DB. I have url like: Code: http://igniter.picturi-celebre.ro/picturi/abstracte/2 The controller for picturi.php is: Code: class Picturi extends CI_Controller { If I access the link :http://igniter.picturi-celebre.ro/picturi , it's show me the content of the picturi.php views. If I access the link: http://igniter.picturi-celebre.ro/picturi/abstracte/2, show: Code: 404 Page Not Found The variable "abstracte", "munti" etc, I need it in the url only for seo. All I want is in picturi.php to get the variable the variable "2 , 3 or 4". Depends on ID I make a select in DB to show other results in picturi.php views. In the classic way it's like you show many categories on a page and on click you show all the products from that category. Thank you in advanced.
[eluser]TheFuzzy0ne[/eluser]
When you access http://igniter.picturi-celebre.ro/picturi/abstracte/2, CodeIgniter is expects to find a method named "abstracte". Since you don't have this method defined, it's throws a 404 error. To get around this, you can either set up a [url="http://ellislab.com/codeigniter/user-guide/general/routing.html"]route[/url] to redirect everything for the picturi controller through the index method, or you can use [url="http://ellislab.com/codeigniter/user-guide/general/controllers.html#remapping"]_remap()[/url] to pass all of your parameters to the index() method.
[eluser]raduenea[/eluser]
It's working. I add in routes.php the code: Code: $route['picturi/:any'] = 'picturi/item_lookup/$1'; In controller picturi.php I add a function: Code: public function item_lookup(){ If I acces the link: http://igniter.picturi-celebre.ro/picturi/abstracte/2 it's show "abstracte". Thanks
[eluser]raduenea[/eluser]
I open the link: http://igniter.picturi-celebre.ro/picturi/abstracte/1 in Firefox and Chrome it's it's show me the correct answer: abstracte In IE show's me: The webpage cannot be found. Is there a problem with some Codeigniter functions in IE ?
[eluser]TheFuzzy0ne[/eluser]
Hi, sorry about the delay. It seems that I'm the only one who wants to help people at the moment... I assume you've fixed this problem? I just tried your link in IE9, and it works without any issues (apart from the PHP errors).
[eluser]raduenea[/eluser]
Thank you for your response. I did't do anything, now I see like you that is working. Very strange. |
Welcome Guest, Not a member yet? Register Sign In |