hello m having trouble here it always display error don't know why please help me i want to insert same only difference in user_id and section_id like this
from_id = 1 , assigned_for = 8 , user_id = 2, section_id = 1, month= january
from_id = 1 , assigned_for = 8 , user_id = 3, section_id = 3, month= january
from_id = 1 , assigned_for = 8 , user_id = 4, section_id = 4, month= january
from_id = 1 , assigned_for = 8 , user_id = 5, section_id = 5, month= january
In view file
Dropdown for months. Dropdown for select employee. heading Allow permissions along with only names sections with checkbox along with dropdown of names comming from heading Allow permissions.
Controller function
$from = $this->_user['user_id'];
if ($this->form_validation->run() == TRUE) {
if ($select_section_ids) {
foreach ($select_section_ids as $id) {$data = array(
'from_id' => $from,
'assigned_for' =>$this->input->post('assigned_for') ,
'user_id' => $this->input->post('user_names'),
'section_id' => $id,
'month' => $this->input->post('month'),
);
$this->my_model->insert($data);
}}
'from_id' - is the loggin id 'assigned_for' - comming from dropdown of select employee 'user_id' - comming from dropdown of name from allow permissions 'section_id' - comming from checkbox 'month'- from dropdown
how to insert this m having error: Column 'user_id' cannot be null
$this->input->post('user_names'), this name is fineuser_names?names? oruser_names? and it can't be null, u always having user id right?from_id,assigned_for,user_id,section_id,month) VALUES ('1', '9', NULL, '1', 'September') because it is an single insert i want it if their are two section and two user id then insert two rows