![]() |
[solved] cannot get uri segment to work - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [solved] cannot get uri segment to work (/showthread.php?tid=24203) |
[solved] cannot get uri segment to work - El Forum - 11-03-2009 [eluser]paigenotfound[/eluser] hi im new to CI and ive been struggling about passing variables in url these past few days; i understand that i can pass the variable by passing it by segments so i have this Code: http://localhost/b3t/index.php/client_profile/cid/4 which will catch the cid value (which is 4) in my cid function within my client_profile controller. Quote:function cid($cid) this works fine but i cant seem to find a way to pass that value to my other controllers which will try to do a db query on one of my models. however i read in the guide that i can also do a $this->uri->segment(3) which i assume will give me the value of 4 but when i try to echo it (for testing purposes) nothing is echoed back in my browser. i also tried assigning it in a variable but echoing that variable returns nothing. Code: $client_id = $this->uri->segment(3); hope someone can help me figure things out. thank you in advance [solved] cannot get uri segment to work - El Forum - 11-03-2009 [eluser]bigtony[/eluser] It's easy to pass the value into another controller, like this: Code: redirect("other_controller/some_function/{$cid}"); [solved] cannot get uri segment to work - El Forum - 11-03-2009 [eluser]rogierb[/eluser] Have you tried echoing segments 1 and 2? [solved] cannot get uri segment to work - El Forum - 11-03-2009 [eluser]saidai jagan[/eluser] I think u shd echo $this->uri->segment(4) ![]() [solved] cannot get uri segment to work - El Forum - 11-03-2009 [eluser]paigenotfound[/eluser] thanks guys i got it working now. thanks for all your help, i used the first method i stated instead of the $this->uri->segment(n) i did the model call within the same function too. |