Codeigniter : Multiple columns of the same row Update query not working
<p>I am not able to update multiple columns of the same row with the row matching the userid in codeigniter.</p>

<p>My controller Code is :</p>

<p>exits.php</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> function update_act_on_resignation(){
    global $SITE,$USER;
   $data = array();
   $data['row'] = new stdClass();
   $data['row'] = $this-&gt;admin_init_elements-&gt;set_post_vals($this-&gt;input-&gt;post());
   $data['offices']=$this-&gt;mod_common-&gt;get_all_offices();
   $clients = currentuserclients();
   $data['roles'] = $this-&gt;mod_common-&gt;get_cat_array('designation','status',"1' AND id &gt; '0",'designation');
   get_city_state_country_array($data,array('cityid'=&gt;$data['row']-&gt;cityid));
   $data['error_message'] = '';
   $data['row']-&gt;id = $this-&gt;uri-&gt;segment(3);
   $data['id'] = $this-&gt;uri-&gt;segment(3);
   $data['action'] = 'add';
   $data['heading'] = 'Add';
   $data['msg_class'] = 'sukses';
   $data['path']=$path;
   $post_action = $this-&gt;input-&gt;post('action');
   if($post_action=='add' || $post_action =='update' ){
    $post_array = $this-&gt;input-&gt;post();
    $action = ($post_action == 'add')?'inserted':'updated';
    //echo '&lt;pre&gt;';print_r($SITE);die;
    echo $post_array['exit_type'] = 'Employee Initiated';
        echo $post_array[$id] = $USER-&gt;id; 
             echo $post_array['custom-105965']; 
             echo $post_array['manager_comments']; 
             echo $post_array['accept']; 
          echo $post_array['agreed_last_date']; 
   

     $data['success_message'] = $this-&gt;exit_common-&gt;update_get_resignation_to_act($post_array,$action);


     if($data['success_message'] == 'Record '.$action.' successfully'){
      $data['row'] = new stdClass();
      $data['row']-&gt;id = $this-&gt;uri-&gt;segment(3);
      $data['row']-&gt;status = 1;

     }

   }
   
   $this-&gt;data['maincontent'] = $this-&gt;load-&gt;view('maincontents/view_resignation_action', $data,true);
   echo "Resignation withdrawn successfully!";
   
   $this-&gt;load-&gt;view('layout', $this-&gt;data);
  }</code></pre>
</div>
</div>
</p>

<p>I am echoing the results got from a form to check if i am receiving the sent form elements and i have received everything properly. i.e i am recieving 67 for $post_array[$id]  Yes for $post_array['custom-105965'] asd for $post_array['manager_comments'] Accept for $post_array['accept'] and 01-01-1970 as $post_array['agreed_last_date'] after the echo.</p>

<p>My Model code is:</p>

<p>exit_common.php</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> function update_get_resignation_to_act($post_array,$action){
   
   $this-&gt;load-&gt;database(); 
   $this-&gt;db-&gt;where('userids', $post_array['id']); 
   $dbdata['discussion'] =  $post_array['custom-105965']; 
   $dbdata['manager_comments'] =  $post_array['manager_comments']; 
     $dbdata['last_status'] =  $post_array['accept']; 
   $dbdata['agreed_date'] =  $post_array['agreed_last_date']; 
 
   $this-&gt;db-&gt;update('pr_resignation_requests', $dbdata);
    return;
      
   
   
  }</code></pre>
</div>
</div>
</p>

<p>I think something is wrong with the model update function. But not able to figure out what is wrong as a similar function is working for updating a single column in db. Am i missing something? Its a mysql db.</p>

<p>My View Code is:</p>

<p>view_resignation_action.php</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;style&gt;
label{font-weight:bold;}

.hbox .col {
    display: table-cell;
    float: none;
    height: 100%;
    vertical-align: top;
 width:100%;
}
&lt;/style&gt;
&lt;div class="new"&gt;
   &lt;section class="content-header"&gt;
          &lt;h1&gt;
   Resignation Action
          &lt;/h1&gt;
          &lt;ol class="breadcrumb" &gt;
            &lt;li&gt;&lt;a href="&lt;?php base_url(); ?&gt;"&gt;&lt;i class="fa fa-home"&gt;&lt;/i&gt; Home&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;People Connect&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="&lt;?php echo base_url(); ?&gt;exits"&gt;Exit Tracker&lt;/a&gt;&lt;/li&gt;
   &lt;li class="active"&gt;Exit Details&lt;/li&gt;
            
          &lt;/ol&gt;
    &lt;/section&gt;
 &lt;input type="hidden" id="page_name" value="requests"&gt; 
 
 &lt;div class="container-fluid"&gt;
                    &lt;div class="row"&gt; 
                        &lt;!-- Thought Day--&gt;
                        &lt;div class="panel wrapper clearfix m-b-none"&gt;
              &lt;!-- Horizontal Form --&gt;
              
                &lt;div class="box-header with-border"&gt;
                  
                &lt;/div&gt;&lt;!-- /.box-header --&gt;
                &lt;!-- form start --&gt;
     &lt;?php if($error_message!=''){?&gt;
        &lt;div class="row-fluid return-message success-message &lt;?php echo $msg_class; ?&gt;"&gt;&lt;?php echo $error_message;?&gt;&lt;/div&gt;
        &lt;?php } else { ?&gt;
                &lt;?php echo form_open('exits/update_act_on_resignation/',array('name'=&gt;'addostcstevent','id'=&gt;'addostcstevent','method'=&gt;'post','autocomplete'=&gt;'on','class'=&gt;'form-horizontal'))?&gt;
     &lt;?php echo form_hidden(array('id'=&gt;$USER-&gt;id,'action'=&gt;$action));?&gt;
     
     &lt;?php foreach($rows as $row){ ?&gt;
                  &lt;div class="panel-body"&gt;
     &lt;div class="control-group form-group"&gt;
      &lt;div class="col-md-6"&gt;
        
            &lt;div class="controls"&gt;  
           &lt;div class="col-md-5"&gt;
          
          &lt;label class="control-label" style="text-align:left"&gt;Name of the employee &lt;/label&gt;
          &lt;div class="controls"&gt;&lt;?php echo $row-&gt;firstname; ?&gt;
          &lt;/div&gt;
          
          &lt;/div&gt;
          &lt;div class="col-md-5"&gt;
          
          &lt;/div&gt;
           &lt;/div&gt;
         &lt;/div&gt;
      &lt;div class="col-md-6 pull-right"&gt;
       &lt;label class="control-label" style="text-align:left"&gt;Date of request &lt;/label&gt;&lt;div class="controls"&gt;
          &lt;?php echo $row-&gt;resignations_date; ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
     &lt;/div&gt; 
     &lt;div class="clearfix"&gt;&lt;/div&gt;     
     &lt;div class="control-group form-group"&gt;
      &lt;div class="col-md-6 "&gt;
       &lt;label class="control-label" style="text-align:left"&gt;Requested Last Working Date&lt;/label&gt;
       &lt;div class="controls"&gt;
       &lt;div class="col-md-10"&gt;
         &lt;?php echo $row-&gt;requested_date; ?&gt;
         &lt;/div&gt;
       &lt;/div&gt;
      &lt;/div&gt;
     
      &lt;div class="col-md-6 pull-right"&gt;
       &lt;label class="control-label"&gt;Reason&lt;/label&gt;
      &lt;div class="controls"&gt;
       &lt;div class="col-md-9"&gt;
       &lt;?php echo $row-&gt;exit_type; ?&gt;  
       &lt;/div&gt;
      &lt;/div&gt;
     &lt;/div&gt;
     
        &lt;div class="col-md-6 pull-right"&gt;
       &lt;label class="control-label"&gt;Comments from Employee&lt;/label&gt;
      &lt;div class="controls"&gt;
       &lt;div class="col-md-9"&gt;
       &lt;?php echo $row-&gt;comments; ?&gt;  
       &lt;/div&gt;
      &lt;/div&gt;
     &lt;/div&gt;
     
     
     
     &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
     
     
     &lt;fieldset id="f1" class="col-md-6 pull-left"&gt; &lt;!-- start fieldset --&gt;
     

     &lt;div class="label"&gt;
     


    &lt;/label&gt;
&lt;/div&gt;
&lt;div class="input"&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;table width="100%" style="text-align:left"&gt;
  
     &lt;label class="control-label" style="text-align:left"&gt;Have you had a discussion with Employee?&lt;/label&gt;
      &lt;table&gt;
       &lt;td valign="top"&gt;
       &lt;input id="custom-105965_0" class="custom-105965" name="custom-105965" value="Yes" type="radio"&gt;
       &lt;label for="custom-105965_0"&gt;Yes
       &lt;br&gt;
       &lt;/label&gt;
       &lt;/td&gt;
       &lt;td valign="top"&gt;
       &lt;input id="custom-105965_1" class="custom-105965" name="custom-105965" value="No" type="radio"&gt;
       &lt;label for="custom-105965_1"&gt;No
       
     &lt;/label&gt;
    &lt;/td&gt;
  &lt;/table&gt;
            &lt;td valign="top"&gt;
                &lt;div class="fieldset" id="bsd-field-custom-105967-group"&gt;
      &lt;div class="col-md-6 pull-left"&gt;
       &lt;label class="control-label"&gt;Please enter your comments&lt;/label&gt;
       &lt;div class="controls"&gt;
       &lt;div class="col-md-12"&gt;
       &lt;textarea required class="form-control" name="manager_comments"&gt;&lt;/textarea&gt;
        &lt;!--&lt;input placeholder="Please enter your comments" class="" id="dateofrequest" type="text" name="todays_date" value=""/&gt; &lt;br&gt;&lt;br&gt;--&gt;
       &lt;/div&gt;
       &lt;/div&gt;
       
       &lt;label class="control-label"&gt;Action&lt;/label&gt;
       &lt;div class="controls"&gt;
       &lt;div class="col-md-9"&gt;
       &lt;?php $dd_list = array(
        'Accept'   =&gt; 'Accepted',
        'Reject'   =&gt; 'Rejected',
        );
       echo form_dropdown('accept', $dd_list, 'Accept');  
       ?&gt; 
       &lt;/div&gt;
       &lt;/div&gt;
       
       
       
       
      
       &lt;label class="control-label"&gt;Agreed Last Working day&lt;/label&gt;
       &lt;div class="controls"&gt;
       &lt;div class="col-md-9"&gt;
        &lt;input placeholder="Agreed Last Working day" class=" m-wrap col-md-8 form-control " id="startdt" type="text" name="agreed_last_date" value="&lt;?php if($row-&gt;requested_date!='') echo date("d-m-Y",$row-&gt;requested_date); ?&gt;" required/&gt;
       &lt;/div&gt;
       &lt;/div&gt;
      
      &lt;br&gt;&lt;br&gt;
      
       &lt;div class="col-md-9"&gt;
       
       
        &lt;/div&gt;
      
      
      
      
      &lt;/div&gt;
    
  
     
                &lt;/div&gt;
    &lt;!-- If its a no --&gt;
               &lt;div class="fieldset" id="bsd-field-custom-105867-group"&gt;
      &lt;div class="col-md-6 pull-left"&gt;
    
      
       &lt;div class="alert alert-success alert-dismissable"&gt;
            &lt;label type="button"&gt;&lt;/label&gt;
            Please have a discussion with the employee.
        &lt;/div&gt;
      
      
      
      &lt;/div&gt;
    
  
     
                &lt;/div&gt;
            &lt;/td&gt;
        &lt;/table&gt;
    &lt;/td&gt;
&lt;/tr&gt;

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
      
     &lt;/fieldset&gt;&lt;!-- End Fiedset --&gt;
     
    &lt;/div&gt;
    &lt;/div&gt;
     &lt;?php }?&gt;
     &lt;div class="clearfix"&gt;&lt;/div&gt;
    &lt;div class=" box-footer"&gt;
     &lt;button type="submit" class="btn btn-info pull-right" style="margin:0px 10px"&gt;submit&lt;/button&gt;
     
    &lt;/div&gt;
    &lt;/form&gt;
        &lt;?php } ?&gt;
    &lt;div class="clearfix"&gt;&lt;/div&gt;
   &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
 &lt;/section&gt;
 &lt;/div&gt;
 &lt;script type="text/javascript" src="&lt;?php echo base_url(); ?&gt;assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="&lt;?php echo base_url(); ?&gt;assets/plugins/select2/select2.min.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="&lt;?php echo base_url(); ?&gt;assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="&lt;?php echo base_url(); ?&gt;assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"&gt;&lt;/script&gt;

&lt;script&gt;
$(".fieldset").hide();
  $(document).ready(function () {
    $("[id^=bsd-field-custom-1059]").hide();
    $(".custom-105965").change(function () {
        $("[id^=bsd-field-custom-1059]").toggle(this.value == 'Yes');
    });
 
});
$(document).ready(function () {
    $("[id^=bsd-field-custom-1059]").hide();
    $(".custom-105965").change(function () {
        $("[id^=bsd-field-custom-1058]").toggle(this.value == 'No');
        $('.alert').show()
    });
 
});
$(document).ready(function(){
  $("#startdt").datepicker({
   dateFormat: 'dd-mm-yy',
   changeMonth: true,
   changeYear: true,
   showButtonPanel: true,
   yearRange: "-90:+0",
   endDate: new Date(),
   autoclose: true
  }).on('changeDate', function (selected) {
   var minDate = new Date(selected.date.valueOf());
   $('#enddt').datepicker('setStartDate', minDate);
  });
  $("#enddt").datepicker({ 
   dateFormat: 'dd-mm-yy',
   changeMonth: true,
   changeYear: true,
   showButtonPanel: true,
   yearRange: "-90:+0",
   endDate: new Date()
  });
  $(".date-picker").datepicker();
   $('.timepicker-default').timepicker();
   $('#report_date').datepicker( {
   format: "mm-yyyy",
    viewMode: "months", 
    minViewMode: "months"
  });
  
   $(".select2").select2({
    placeholder: "Select an option",
    allowClear: true
   });
    $("#asset_type").change(function(){
     if($(this).val() == '-1') {
      $("#new_type").show();
     }
     else
     {
      $("#new_type").hide();
     }
    });

    $("#manufacturer").change(function(){
     if($(this).val() == '-1') {
      $("#new_manufacturer").show();
     }
     else
     {
      $("#new_manufacturer").hide();
     }
    });

    $("#supplier").change(function(){
     if($(this).val() == '-1') {
      $("#new_supplier").show();
     }
     else
     {
      $("#new_supplier").hide();
     }
    });
  });
  

  
&lt;/script&gt;</code></pre>
</div>
</div>
</p>

<p>Mysql Table is :<a href="https://i.stack.imgur.com/UOXLf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UOXLf.png" alt="enter image description here"></a></p>