<tr><th>Option Subject</th>
<th>
<input type="checkbox" name="skills" id="skills[]" value="C++"> C++<br>
<input type="checkbox" name="skills" id="skills[]" value="JAVA"> JAVA<br>
<input type="checkbox" name="skills" id="skills[]" value="HTML"> HTML<br>
<input type="checkbox" name="skills" id="skills[]" value="PHP"> PHP<br>
<input type="checkbox" name="skills" id="skills[]" value="ASP.NET">ASP.NET<br>
<font color="#FF0000"><?php echo form_error('skills');?></font>
</th>
</tr>
CONTROLER 公共函数insert() { $ skills = $ this-&gt; form_validation-&gt; set_rules('技能','选项主题','必需');
$data = array(
'skills' => implode(",", $skills);
);
}
if(isset($options['skills']))
$this->db->set('skills',($options['skills']));
$this->db->insert("regi_user");
return $this->db->insert_id();
答案 0 :(得分:0)
您必须将内爆值转换为字符串。
尝试以下代码
$data = array(
'skills' => json_encode(implode(",", $skills));
);
$this->db->insert("regi_user");
return $this->db->insert_id();
答案 1 :(得分:0)
要在表格中添加多个值,请尝试以下代码。
$language = $this->input->post('skills');
if (is_array($language) && !empty($language))
{
foreach($language as $lan)
{
$insert['language'] = $lan;
$this->db->insert("table name");
}
}