title: Codeigniter Updating database row by passing id in uri
body: <p>I have an edit-button for each row in a list (view1). When that edit button gets clicked, a site opens where I can edit the row fields (view2). It passes the row's id to view2 correctly (id 11 in example below) which uri segment I call in the model to update this row 11 with array data from controller which array data I also passed to the model. But it still does not update. Thank you for your help.</p>
  
  <p>(view 1):</p>
  
  <pre><code>//clicking edit button - redirects and passes row id 11 to view 2
  &lt;a href='&lt;?= site_url("admin/admins/update_site/$admin-&gt;id") ?&gt;'&gt;&lt;img src='&lt;?= base_url('media/admin/images/icons/config.png'); ?&gt;'/&gt;&lt;/a&gt;
  </code></pre>
  
  <p>(view 2):</p>
  
  <pre><code>// view 2 opens where I can edit the row fields 
  //url is now: www.site.com/admin/admins/update_site/11:
  
  &lt;form action="&lt;?= site_url('admin/admins/update'); ?&gt;" method="POST"&gt;
      Username: &lt;br&gt;
      &lt;input type='text' name='username'/&gt;&lt;br&gt;
      Password: &lt;br&gt;
      &lt;input type='password' name='password' /&gt;&lt;br&gt;
      &lt;input type='submit' name='submit' value='Save' /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>//making an array with updated data and send it to the model
  public function update(){
     $update = array(
          'username' =&gt; $this-&gt;input-&gt;post('username'),
          'password' =&gt; $this-&gt;input-&gt;post('password')
     );
  
    $this-&gt;load-&gt;model('admin/admins_model');
    $this-&gt;admins_model-&gt;update_admin($update);
    redirect(site_url('admin/admins/read'));
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>//update row 11 (from uri segment) the with the array data from controller 
  public function update_admin($update){
      $this-&gt;db-&gt;where('id', $this-&gt;uri-&gt;segment(4));
      $this-&gt;db-&gt;update('admins', $update);
  }
  </code></pre>