Welcome Guest, Not a member yet? Register   Sign In
How can I dynamically get the ID from a row in my database?
#2

[eluser]jedd[/eluser]
I'm confused by your code and your words.

When you say 'get the ID from a row in my database' do you mean get the ID from a row in your database, or do you mean take the ID as given in the URL?

If your controller (shown above) was called Page, say, and your method was update(), then you need to have this kind of construct in there:
Code:
function update ( $page_id = 0 )    {
        if ($page_id == 0)
             // bomb out somehow ;
        $data = array(
            'title' => $this->input->post('title'),
            'content' => $this->input->post('content')
            );
        $this->crud_model->update_entry($page_id, $data);
        ...

Your URL would be http://..../page/update/27

Your model now takes two parameters - the first is the row.id to manipulate.

Is this the kind of thing you mean?


Messages In This Thread
How can I dynamically get the ID from a row in my database? - by El Forum - 09-12-2009, 07:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB