In your Model next part should be
$data[] = array( $code='code' => $_POST['code'][$i], 'price' => $_POST['sell'] );
replaced by
$data[] = array( 'code' => $_POST['code'][$i], 'price' => $_POST['sell'] );
and update the values you should use update_batch instead of insert_batch
$this->db->update_batch('yourtableName', $data, 'code');
Replace yourtableName your original table name and code used for the where key, so you do not need to use $this->db->where('code',$code) .
Link: CodeIgniter .
source share