title: if multiple checkbox checked, database column updated with 0/1 in codeigniter
body: <p>I am trying to update the database by using checkboxes. if i check the check-box the existing column of database will be updated with the 0/1 value. So far i have done using ajax/jquery. 
  first problem  is the jquery which i am trying, it only updates the first checkbox of the the whole data and secondly as soon i refresh the page it updates automatically it is updating with the column replacing first row to [BLANK] only. means not showing 0 neither 1. I wonder if i can do with the checkboxes. Its my first try using ajax.
  Thanks for consideration!!</p>
  
  <p><strong>CONTROLLER :</strong></p>
  
  <pre><code>   public function user_status()
   {
  
   if ( $this-&gt;session-&gt;userdata('session_status'))
      {
          $this-&gt;load-&gt;model('admin/admin_user_mngmt_model');
          $reg_id = $this-&gt;input-&gt;post('reg_id');
          $status = $this-&gt;input-&gt;post('status');
          $status = $this-&gt;admin_user_mngmt_model-&gt;update_status($reg_id, $status);
         if($status == true){
                // echo "true";
                $this-&gt;load-&gt;view('admin_view/admin_user_mngmt/user-management', $status);
         }else{
                 echo "false";
           }
  
          echo "&lt;pre&gt;" ;
          print_r($status);
      }
      else {
          redirect ('admin/admin_control/admin_login');
      }
  
   }
  </code></pre>
  
  <p><strong>MODEL :</strong> </p>
  
  <pre><code>public function update_status($reg_id, $status)
  {
  
  $sql = "UPDATE fw_registeration SET status=? WHERE reg_id=?";
  $result = $this-&gt;db-&gt;query($sql, array($status, $reg_id));
  
  if($result){
      return TRUE;
  }else{
      return FALSE;
  }   
  
  }
  </code></pre>
  
  <p><strong>VIEW :</strong> </p>
  
  <p><strong>for checkbox :</strong> </p>
  
  <pre><code>  &lt;td&gt;&lt;input type="hidden" name="user_status_id" class="mycheckbox" id="user_status_id"  value="&lt;?php echo $da['reg_id']; ?&gt;"/&gt;
        &lt;td&gt;&lt;input type='checkbox' class='user_status' id='user_status' value=''/&gt;
         &lt;p id='user_status_msg'&gt;&lt;/p&gt;
  </code></pre>
  
  <p><strong>Jquery :</strong> </p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  $('document').ready(function(){
  
      var link =  "&lt;?php echo base_url();?&gt;" ;
       alert('loaded');
      $(".user_status").prop('checked', true); 
  
  
      var status = $(this).val(); 
      var reg_id = $("#user_status_id").val();
  
      alert(reg_id);
      $.post(link + "admin/admin_control/user_status", {reg_id:reg_id, status:status,  ajax : 1}, function(data){
          alert(data);
  
      //  if(data == true){
              $("#user_status_msg").html('user is updated.');
  
      //}
  
      });
  
  });
  
  &lt;/script&gt;   
  </code></pre>