I have a form with 8 input fields. Now I don't want to update a field in the database if it's left empty.
This are the fields that I like to check. if empty do not update them and leave the original value. How to do this?
This is my function in my controller
function update_profile(){
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'telefoon' => $this->input->post('telefoon'),
'gsm' => $this->input->post('gsm'),
'facebook' => $this->input->post('facebook'),
'twitter' => $this->input->post('twitter'),
'portfolio' => $this->input->post('portfolio'),
'profilefoto' => $this->input->post('browse')
);
$this->kdg_model->update_profile($data);
}
My model
function update_profile($data) {
$session_id = $this->session->userdata('user');
$this->db->where('user', $session_id);
$this->db->update('user', $data);
}