title: CodeIgniter Update query not working
body: <p>I want to terminate a employee from the system. When clicks on terminate button it will popup a moadal asking whether wants to terminate or cancel. If terminate database value resign should be updated as 0, but right now button does not working.</p>
  
  <p>Here is my code</p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>public function ajax_list()
  {
      $list = $this-&gt;employees-&gt;get_datatables();
  
      $data = array();
      $no = $_POST['start'];
      foreach ($list as $emp) {
          $no++;
          $row = array();
          $row[] = $emp-&gt;employee_id;
          $row[] = $emp-&gt;name;
          $jid = $emp-&gt;job_title;
          $desigdata = $this-&gt;employees-&gt;GetJobTitlebyID($jid);
          $row[] = $desigdata-&gt;desc;
          $did = $emp-&gt;department;
          $deptdata = $this-&gt;employees-&gt;GetDepartmentbyID($did);
          $row[] = $deptdata-&gt;title;
          $secid = $emp-&gt;section;
          $secdata = $this-&gt;employees-&gt;GetSectionbyID($secid);
          $row[] = $secdata-&gt;desc;
  
  
          //add html for action
          $row[] = '&lt;a class="btn btn-sm btn-primary" href="javascript:void()"  onclick="terminate_emp('."'".$emp-&gt;id."'".')"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt; Terminate&lt;/a&gt;';
  
  
          $data[] = $row;
      }
  
      $output = array(
          "draw" =&gt; $_POST['draw'],
          "recordsTotal" =&gt; $this-&gt;employees-&gt;count_all(),
          "recordsFiltered" =&gt; $this-&gt;employees-&gt;count_filtered(),
          "data" =&gt; $data,
      );
  
      echo json_encode($output);
  }
  
  
  public function ajax_terminate()
      {
          $this-&gt;_validate();
          $data = array(
              'resign' =&gt; $this-&gt;input-&gt;post('resign'),
  
          );
          $this-&gt;employees-&gt;update(array('id' =&gt; $this-&gt;input-&gt;post('id')), $data);
          echo json_encode(array("status" =&gt; TRUE, "id" =&gt; $this-&gt;input-&gt;post('id')));
      }
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code> function terminate_emp($data)
   {
       $this-&gt;db-&gt;where('resign', 0);
       $this-&gt;db-&gt;update('employees', $data);
   }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>function terminate_emp(id)
      {
          save_method = 'update';
          $('#form')[0].reset(); 
          $('.form-group').removeClass('has-error'); 
          $('.help-block').empty(); 
  
          //Ajax Load data from ajax
          $.ajax({
              url : "&lt;?php echo site_url('employees_con/ajax_terminate/')?&gt;/" + id,
              type: "GET",
              dataType: "JSON",
              success: function(data)
              {
                  $('[name="id"]').val(data.id);
  
                  if(data.resign == 1)
                  {
                      //$('[name="resign"]').val(data.resign);
                      $('#resign').prop('checked', true);
                  }
                  $('[name="resign"]').val(data.resign);
  
                  $('#modal_formterminate').modal('show'); // show bootstrap modal when complete loaded
                  $('.modal-title').text('Terminate Employee'); // Set title to Bootstrap modal title
  
              },
              error: function (jqXHR, textStatus, errorThrown)
              {
                  alert('Error get data from ajax');
              }
          });
      }
  
  
  
  &lt;div class="modal fade" id="modal_formterminate" role="dialog"&gt;
  
      &lt;div class="modal-dialog modal-full" style="max-width: 600px"&gt;
  
      &lt;div class="modal-content"&gt;
  
          &lt;div class="modal-header bg-blue-steel bg-font-blue-steel"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
              &lt;h3 class="modal-title bold uppercase"&gt;Person&lt;/h3&gt;
          &lt;/div&gt;
  
          &lt;div class="modal-body form"&gt;
              &lt;form action="#" id="form" class="form-horizontal"&gt;
                  &lt;input type="hidden" value="" name="id"/&gt;
                  &lt;div class="form-body"&gt;
  
                      &lt;div id="empWizard"&gt;
  
  
                          &lt;p style="color: #0000cc"&gt;&lt;b&gt;Are You sure to Terminate this employee&lt;/b&gt;&lt;/p&gt;
  
                      &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;/form&gt;
          &lt;/div&gt;
  
          &lt;div class="modal-footer"&gt;
              &lt;button type="button" id="btnSaveterminate" onclick="save()" class="btn btn-primary"&gt;Terminate&lt;/button&gt;
              &lt;button type="button" class="btn btn-danger" data-dismiss="modal"&gt;Cancel&lt;/button&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;&lt;!-- /.modal-content --&gt;
      &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
  
  &lt;/div&gt;
  </code></pre>