Welcome Guest, Not a member yet? Register   Sign In
Can't get segment() info
#1

[eluser]drakenlx[/eluser]
Hello Everybody

I'm new to CI and wrote a very simple code in which I can't get segment info; the plan is to list a table with 3 columns id_user / name / and a Picture Anchor pointing to the edit method in the main controller passing the id_user as a parameter, I get redirected to:

http://localhost/cigniter/index.php/user/edit/3

But when I want to get segment info in the "edit" function always get:
echo $this->uri->total_segments() // displays: 0
echo $this->uri->segment(0,"No Data") // displays: No Data
echo $this->uri->segment(1,"No Data") // displays: No Data
echo $this->uri->segment(2,"No Data") // displays: No Data
echo $this->uri->segment(3,"No Data") // displays: No Data

Do you know if need to edit something in CI config or php.ini, etc. ?
Thank You

The Code is:
Controller: User.php
Code:
<?php
class User extends Controller{

    function User(){
        parent:: Controller();
        $this->load->database('default');
        $this->load->helper('html');
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->library('uri');
    }
    
    function index(){        
        $data['rs_users'] = $this->db->query('SELECT id_user, name FROM users');
        $this->load->view("user_v",$data);
    }

    function edit(){
        echo  $this->uri->total_segments();
        echo  $this->uri->segment(0,"No Data");
        echo  $this->uri->segment(1,"No Data");
        echo  $this->uri->segment(2,"No Data");
        echo  $this->uri->segment(3,"No Data");
    }
}

View: user_v.php
Code:
<html>
..
    <table>
        <tr>
            <td>id_user</td>
            <td>name</td>
            <td>edit</td>
        </tr>
        &lt;?php foreach ($rs_users->result() as $user): ?&gt;
        <tr>
            <td>&lt;?php echo $user->id_user;?&gt;</td>
            <td>&lt;?php echo $user->name;?&gt;</td>
            <td>&lt;?php echo anchor('user/edit'.$user->id_user,img('images/edit.jpg'));?&gt;</td>
        </tr>
        &lt;?php endforeach; ?&gt;
     </table>
..
&lt;/html&gt;


Messages In This Thread
Can't get segment() info - by El Forum - 07-24-2010, 09:31 AM
Can't get segment() info - by El Forum - 07-24-2010, 09:47 AM
Can't get segment() info - by El Forum - 07-24-2010, 09:58 AM
Can't get segment() info - by El Forum - 07-24-2010, 10:01 AM
Can't get segment() info - by El Forum - 07-24-2010, 10:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB