[eluser]xitclub[/eluser]
Hi all,
This is my first post in community.
The problem is i wanted to store multiple checkbox values in database but its storing only first value in database.
my code is
Form
Code:
<div class="row ex-row">
<div class="col-lg-3 col-md-3 col-sm-3 ex-col">
<h4>Area of Expertise</h4>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 ex-chks">
<label class="checkbox-inline">
<input type="checkbox" id="ex1" value="iOS" name="expertise[]"> iOS (Native)
</label>
<label class="checkbox-inline">
<input type="checkbox" id="ex2" value="Android" name="expertise[]"> Android (Native)
</label>
<label class="checkbox-inline">
<input type="checkbox" id="ex3" value="HTML5" name="expertise[]"> HTML5
</label>
<br />
<label class="checkbox-inline">
<input type="checkbox" id="ex4" value="Corona" name="expertise[]"> Corona
</label>
<label class="checkbox-inline">
<input type="checkbox" id="ex5" value="Titanium" name="expertise[]"> Titanium
</label>
<label class="checkbox-inline">
<input type="checkbox" id="ex6" value="BlackBerry" name="expertise[]"> BlackBerry
</label>
<br />
<label class="checkbox-inline">
<input type="checkbox" id="ex7" value="PhoneGap" name="expertise[]"> PhoneGap
</label>
<label class="checkbox-inline">
<input type="checkbox" id="ex8" value="Unity" name="expertise[]"> Unity
</label>
</div>
Model Code
Code:
public function UpdateExpertise($id) {
$user_id = $id;
$position = $this->security->xss_clean($this->input->post('position'));
$expertise = $this->security->xss_clean($this->input->post('expertise'));
foreach($expertise as $value){
$ex_val = $value.",";
}
$experience = $this->security->xss_clean($this->input->post('experience'));
$freelaning = $this->security->xss_clean($this->input->post('freelancing'));
if(isset($_POST['submit'])){
$data = array(
'user_position' => $position,
'user_expertise' => $ex_val,
'user_experience' => $experience,
'freelancing' => $freelaning
);
$this->db->where('user_id', $user_id);;
$query = $this->db->update('users', $data);
if($query){
return TRUE;
}
else {
return FALSE;
echo $this->db->display_errors();
}
}
}