CodeIgniter form_multiselect CodeIgniter form_multiselect codeigniter codeigniter

CodeIgniter form_multiselect


The easiest way would be to set up all the common parameters and then insert data on each foreach iteration of the $this->input->post('EMPLOYEES_id').

 foreach($this->input->post('EMPLOYEES_id') as $eid){      // insert data using $uid as the employer id here }


$employees = $this->input->post('EMPLOYEES_id')

$employees is actually an array of IDs, so you must iterate it (use foreach). Do a var_dump($employees) by yourself to check it's structure.

The final code should look like this:

// Set all the data$insert_data = new stdClass();$insert_data->NOTIFICATIONS_toname = $notify_user_info[0]->EMPLOYEES_firstname . ' ' . $notify_user_info[0]->EMPLOYEES_surname;$insert_data->NOTIFICATIONS_toemail = $notify_user_info[0]->EMPLOYEES_email;$insert_data->NOTIFICATIONS_subject = 'A new message has been added for you';$insert_data->NOTIFICATIONS_htmlbody = $notification_body;foreach($this->input->post('EMPLOYEES_id') as $employee_id){  $insert_data->EMPLOYEES_id = $employee_id;  // Save to new notification to the database  $this->Notifications_model->create($insert_data);}