title: How to update the exact row in table using codeigniter
body: <p>My view page:
  <a href="https://i.stack.imgur.com/GZB9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GZB9s.png" alt="enter image description here"></a></p>
  
  <p>In this picture i am getting data like <code>loan no</code>, <code>partyname</code>, <code>coll.amt</code> using <code>date</code> (ie it display the data in that particular date when i gave, from "collection" table)</p>
  
  <p>If i have entered the rep amt  for <code>loan no</code> 2 but i didn't give to <code>loan no</code> 1, 3. when i pressed <code>ok button</code> the rep amt should be updated in that "collecion" table for exact loan number and date.</p>
  
  <p>My Model code:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function batchinsert($data){
      $session_data = $this-&gt;session-&gt;userdata('logged_in');
      $data['username'] = $session_data['repname'];
      $LDate = $this-&gt;input-&gt;post('CDate');
      $date = str_replace('/', '-', $LDate);
      $newDate = date("Y-m-d", strtotime($date));
      $lno = $this-&gt;input-&gt;post("Sno");
      $count = count($data['Sno']);
      for($i = 0; $i&lt;$count; $i++){ 
          $entries2[] = array(               
              'receive_amt'=&gt;$data['ramt'][$i],
  
              ); 
      }
      $this-&gt;db-&gt;where('loanno',$lno);
      $this-&gt;db-&gt;where('collection_date',$newDate);
      $this-&gt;db-&gt;update_batch('collection',$entries2);
      //        $this-&gt;db-&gt;insert_batch('test', $entries2);
      redirect('Collection_Entry','refresh');
  }
  </code></pre>
  
  <p>My Controller code:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function Collection_Insert(){
      $this-&gt;load-&gt;model('User_model');
      $result = $this-&gt;User_model-&gt;batchinsert($_POST);
  }
  </code></pre>
  
  <p>My View page Code:  </p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;table class="table table-bordered table-striped table-xxs" id="tb3"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Loan No&lt;/th&gt;
              &lt;th&gt;Party Name&lt;/th&gt;
              &lt;th&gt;Coll.Amt&lt;/th&gt;
              &lt;th&gt;Rep Amt&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;?php
      //echo '&lt;pre&gt;';print_r($result2);exit();
      if(!empty($query)){
          foreach($query as $row){
      ?&gt;
          &lt;tr &gt;
          &lt;td &gt;&lt;input style="width:50px" type="text" class="form-control input-xs" name="Sno[]" id="Sno" value="&lt;?=$row['loanno'];?&gt;"&gt;&lt;/td&gt;
  
          &lt;td&gt; &lt;input style="width:180px" type="text" class="form-control input-xs" name="name[]" id="Amount" value="&lt;?=$row['pname'];?&gt;"&gt;&lt;/td&gt;
  
          &lt;td &gt;&lt;input style="width:80px" type="text" class="form-control input-xs amt" name="Amount[]" id="Bankname" value="&lt;?=$row['collection_amt'];?&gt;"&gt;&lt;/td&gt;
  
          &lt;td &gt;&lt;input style="width:80px" type="text" class="form-control input-xs ramt" name="ramt[]" id="Chqamt" value="&lt;?=$row['receive_amt'];?&gt;" autofocus&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;?php
          }
      }?&gt; 
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>please solve this problem.</p>