Get data based on the URL but using the same function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Get data based on the URL but using the same function (/showthread.php?tid=41738) |
Get data based on the URL but using the same function - El Forum - 05-15-2011 [eluser]Dannymx[/eluser] Well, basically what I am looking to do is something like this: The user will be able to type an URL like: Quote:example.com/list/schoolname1and the user will see data from the School 1 or Quote:example.com/list/schoolname2and here the user get data from school 2 etc. So I have a function called index Code: function index(){ The function will be used with any school that is typed since the functionality is the same. I used routing to remove the index from the URL '(/list/(:any)', but what I want to know is how to make the function to identify what school was typed in the URL and then get the data based on that segment, and also even if they type SchOoLNamE1 (case insensitive). Thanks in advance. Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]osci[/eluser] Code: function index($school='') { Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]Dannymx[/eluser] [quote author="osci" date="1305544408"] Code: function index($school='') { I printed the $school value and I get "(:any)" This is making conflict with the uri routing. Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]osci[/eluser] post your route, it must be wrong if it's returning "(:any)" Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]Dannymx[/eluser] [quote author="osci" date="1305545821"]post your route, it must be wrong if it's returning "(:any)"[/quote] Code: $route['list/(:any)'] = "list/index/(:any)"; Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]osci[/eluser] Code: $route['list/(:any)'] = "list/index/$1"; Get data based on the URL but using the same function - El Forum - 05-16-2011 [eluser]Dannymx[/eluser] [quote author="osci" date="1305545994"] Code: $route['list/(:any)'] = "list/index/$1"; Thank you, the parameter thing and that routing did the trick :-) |