Welcome Guest, Not a member yet? Register   Sign In
Storing Multople Checkbox Values in Database
#1

[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">
       &lt;input type="checkbox" id="ex1" value="iOS" name="expertise[]"&gt; iOS (Native)
     </label>
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex2" value="Android" name="expertise[]"&gt; Android (Native)
     </label>
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex3" value="HTML5" name="expertise[]"&gt; HTML5
     </label>
     <br />
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex4" value="Corona" name="expertise[]"&gt; Corona
     </label>
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex5" value="Titanium" name="expertise[]"&gt; Titanium
     </label>
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex6" value="BlackBerry" name="expertise[]"&gt; BlackBerry
     </label>
     <br />
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex7" value="PhoneGap" name="expertise[]"&gt; PhoneGap
     </label>
     <label class="checkbox-inline">
       &lt;input type="checkbox" id="ex8" value="Unity" name="expertise[]"&gt; 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();
     }
}

    }


Messages In This Thread
Storing Multople Checkbox Values in Database - by El Forum - 09-05-2014, 05:31 AM
Storing Multople Checkbox Values in Database - by El Forum - 09-05-2014, 05:56 AM
Storing Multople Checkbox Values in Database - by El Forum - 09-05-2014, 08:23 AM
Storing Multople Checkbox Values in Database - by El Forum - 09-07-2014, 03:21 PM
Storing Multople Checkbox Values in Database - by El Forum - 09-07-2014, 07:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB