Welcome Guest, Not a member yet? Register   Sign In
help, updating excisting row in database[SOLVED]
#1

[eluser]Ivar89[/eluser]
hi,

I recently started using codeIgniter and I am lost atm.
I need to update the last row in my database, this is my code so far in model:
Code:
$sql = $this->db->query ('Select * From tblpage Where ID_Page = (Select Max(ID_Page) From tblpage)');
        $id['ID_Page'] = $sql;
        
        if(isset($data['strPageUrl']))
            $this->db->set('strPageUrl',$data['strPageUrl']);

        if(isset($data['strTitle']))
            $this->db->set('strTitle',$data['strTitle']);

        if(isset($data['strPageName']))
            $this->db->set('strPageName',($data['strPageName']));
            
        $this->db->where('ID_Page',$id);
        $query = $this->db->update('tblpage');
        
        return $this->db->affected_rows();
this is my controler:
Code:
{
        $this->insert_model->Insert_Description($_POST);
        $this->load->view('page/step3');
    }
Now if I delete; $this->db->where('ID_Page',$id); it updates all the table.
If it stays there I get a database error:

how can I tell him to just update the LAST row?

thanks,


Messages In This Thread
help, updating excisting row in database[SOLVED] - by El Forum - 03-22-2010, 04:46 AM
help, updating excisting row in database[SOLVED] - by El Forum - 03-22-2010, 07:26 AM
help, updating excisting row in database[SOLVED] - by El Forum - 03-23-2010, 03:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB