I do not understand about uri->segment
on CodeIgniter.
as the following example, I have a table with the fields:
| Id_comment | id_alat | user |
|:-----------|------------:|:------------:|
| 1 | 45 | irwan |
if i call $id = $this->uri->segment(4);
It returns the user
field.
How do I return the id_comment
field instead?
For example, your url look alike: http://localhost/yourProject/users/edit/1/john/33
So you have five parameters:
1. users - the controller
2. edit - the function
3. 1 - the id of user
4. john - the name of user
5. 33 - the age of user
In your route.php
file you should create the following route:
$route['users/edit/(:num)/(:any)/(:num)'] = 'users/edit/$1/$2/$3;
Finally, in your controller you are able to access the parameters from your url by uri->segment()
or..
public function edit($id, $name, $age)
{
echo $id;
}