Reputation: 1
<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 public function insert() { $skills=$this->form_validation->set_rules('skills', 'Option Subject','required');
$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();
Upvotes: 0
Views: 1381
Reputation: 289
To add multiple value in table try following code.
$language = $this->input->post('skills');
if (is_array($language) && !empty($language))
{
foreach($language as $lan)
{
$insert['language'] = $lan;
$this->db->insert("table name");
}
}
Upvotes: 0
Reputation: 415
You have to convert imploded value to string.
Try the following code
$data = array(
'skills' => json_encode(implode(",", $skills));
);
$this->db->insert("regi_user");
return $this->db->insert_id();
Upvotes: 0