CodeIgniter Forums

Full Version: [solved] cannot get uri segment to work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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


which will catch the cid value (which is 4) in my cid function within my client_profile controller.

Quote:function cid($cid)
echo $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.

$client_id = $this->uri->segment(3);
echo $client_id;

hope someone can help me figure things out. thank you in advance

El Forum

It's easy to pass the value into another controller, like this:

El Forum

Have you tried echoing segments 1 and 2?

El Forum

[eluser]saidai jagan[/eluser]
I think u shd echo $this->uri->segment(4) Smile

El Forum

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.