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
在视图文件
中下降数月。 选择员工的下拉列表。 标题允许权限以及仅名称 带有复选框的部分以及从标题允许权限中提取的名称下拉列表。
控制器功能
$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' - 是登录ID 'assigned_for' - 来自精选员工的下拉列表 'user_id' - 从允许权限下拉名称 'section_id' - 来自复选框 '月' - 来自下拉
如何插入此m有错误:列'user_id'不能为空
答案 0 :(得分:1)
您对用户ID使用了错误的索引名称,asyncContext.start {
while(true) {
// write event
}
}
是一个数组且等于team_lead
,因此您可以使用section_ids
的$ key来获取正确的section_ids
。
示例:强>
team_leads
另请注意,如果<?php
foreach ($select_section_ids as $key => $id) {
$data = array(
'from_id' => $from,
'assigned_for' => (isset($_POST['assigned_for']) ? $_POST['assigned_for'] : 0),
'user_id' => $_POST['team_leads'][$key], // this will use the key of section_ids, which is equal to team_leads.
'section_id' => $id,
'month' => $_POST['month'],
);
?>
不等于team_leads
,则必须添加以下支票:
section_ids