Welcome Guest, Not a member yet? Register   Sign In
Multiple row update
#3

[eluser]cahva[/eluser]
Roughly something like this:
Code:
function Update()
{

    if ($this->input->post('ID'))
    {
        foreach($_POST['ID'] as $k=>$v)
        {
            $this->db->update('my_table',
                array(
                    'FirstName' => $_POST['FirstName'][$k],
                    'Surname' => $_POST['Surname'][$k]
                ),
                array('ID' => (int) $v)
            );
        }
    }
    
    // Load some view or do something else
    
}

This is just an example and you should not use it like that. Theres no input checking and you should pass those values to your model which would update the database. But hopefully you'll get the idea.


Messages In This Thread
Multiple row update - by El Forum - 01-23-2011, 03:45 PM
Multiple row update - by El Forum - 01-23-2011, 04:18 PM
Multiple row update - by El Forum - 01-23-2011, 08:50 PM
Multiple row update - by El Forum - 01-24-2011, 02:30 PM
Multiple row update - by El Forum - 01-24-2011, 04:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB