Passing values |
[eluser]Suhas nazir[/eluser]
Is it possible to pass values to the index function in codeigniter?????
[eluser]mddd[/eluser]
The index function in a controller is only called when no method is provided. For example: Code: www.example.com/mycontroller -> this calls the index method in the mycontroller controller If you DO want to call the index method with an argument, you need to use the _remap method. Example: Code: function _remap() You might want to do some more checking, for instance if www.example.com/mycontroller is called, segment(1) is 'mycontroller' and segment(2) is 'index'. So you should check if the argument is 'index' before handling it. but I hope the idea is clear now. For more info, check the 'routing' page in the CI manual.
[eluser]pickupman[/eluser]
What are wanting to do because the question has many answers? The one mddd gave you is correct, and can also been done like: Code: //In Controller Or perhaps you want to define a default 3rd segment to automatically be set by default Code: function index($id = 0){ |
Welcome Guest, Not a member yet? Register Sign In |