CodeIgniter Forums
How to update ALOT of fields from a form - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to update ALOT of fields from a form (/showthread.php?tid=47850)



How to update ALOT of fields from a form - El Forum - 12-24-2011

[eluser]trope[/eluser]
Being fairly new to CI, I am wondering if there is a better way to update a table from a form, other than the way I have below.

My entire form corresponds with the field names in the table.

Thanks!

Code:
$update_data = array();
    
    $update_data[""] = $this->input->post("field1");
    $update_data[""] = $this->input->post("field2");
    $update_data[""] = $this->input->post("...");
    $update_data[""] = $this->input->post("...");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    $update_data[""] = $this->input->post("");
    
      $this->user_model->update($update_data);