Welcome Guest, Not a member yet? Register   Sign In
Multiple insert not working but single is.
#1

[eluser]debow[/eluser]
I'm using datagrid that has a save-selected option. However it's only saving a single row when selected or if you select multiple it only saves the last row edited. Here is the update function. Am I doing something wrong?

Code:
public function ext_update() {

        $records = explode('||', $_POST['postdata']);

        foreach ($records as $row) {
            $field = explode(';', $row);

            $data = array(
                'name' => $field[1],
                'event' => $field[2],
                'result' => $field[3],
                'status' => $field[4]
            );

            if (is_numeric($field[0])) {
                $this->db->where('id', $field[0]);
                $this->db->update('pullup_results', $data);
                
            } else {
                $this->db->insert('pullup_results', $data);
            }
        }
    }




Theme © iAndrew 2016 - Forum software by © MyBB