title: How to edit Records using CodeIgniter
body: <p>how do i edit my records?i keep getting to wrong pages.. thanks in advance really need help
  i based my code in my delete function i got from yesterday but i have no luck doing so in edit
  controller</p>
  
  <pre><code>    function update()
  {
      $booking=array(
          'name'=&gt;$this-&gt;input-&gt;post('name'),
          'nationality'=&gt;$this-&gt;input-&gt;post('nationality'),
          'number_of_guest'=&gt;$this-&gt;input-&gt;post('number_of_guest'),
          'date'=&gt;$this-&gt;input-&gt;post('date'),
          'package'=&gt;$this-&gt;input-&gt;post('package'),
          'request'=&gt;$this-&gt;input-&gt;post('request')
          );
  
      $this-&gt;site_model-&gt;update_record($booking);
      $this-&gt;edit();
  }
  </code></pre>
  
  <p>site_model</p>
  
  <pre><code>      function update_record($booking)
  {
      $this-&gt;db-&gt;where('id', 1);
      $this-&gt;db-&gt;update('booking', $booking);
  }
  </code></pre>
  
  <p>edit.php</p>
  
  <pre><code>      &lt;div id="bgbp"&gt;&lt;/div&gt;
  &lt;div id="bp"&gt;
      &lt;h2 class="nb"&gt;Update&lt;/h2&gt;
      &lt;?php echo form_open('site/update');?&gt;
      &lt;div id="nems"&gt;
          &lt;p&gt;
              &lt;label for="name"&gt; Guest name(s): &lt;/label&gt;
              &lt;input type="text" name="name" id="name" placeholder="Name(s)"/&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="nat"&gt;
          &lt;p&gt;
              &lt;label for="nationality"&gt;Nationality: &lt;/label&gt;
              &lt;input type="text" name="nationality" id="nationality" placeholder="Nationality"/&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="nog"&gt;
          &lt;p&gt;
              &lt;label for="number_of_guest"&gt; Number of Guest:&lt;/label&gt;
              &lt;input type="number" name="number_of_guest" id="number_of_guest" placeholder="Number of Guest"/&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="doa"&gt;  
          &lt;p&gt;
              &lt;label for="date"&gt; Date of Arrival:&lt;/label&gt;
              &lt;input type="date" name="date" id="date"/&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="mainselection"&gt;
  
          &lt;select name="package" id="input7"&gt;
              &lt;option value="" style="display:none"&gt;Choose Package to avail&lt;/option&gt;
              &lt;option value="Package A. Half - day City Tour"&gt;Package A. Half - day City Tour&lt;/option&gt;
              ...
              &lt;option value="Package B. Honda Bay Island Hopping"&gt;Package B. Honda Bay Island Hopping&lt;/option&gt;
              &lt;option value="Package C. St. Paul's Subterranean River National Park or Underground River"&gt;Package C. St. Paul's Subterranean River National Park or Underground River&lt;/option&gt;                              
          &lt;/select&gt;
      &lt;/div&gt;
      &lt;div id="or"&gt;
          &lt;p&gt;
              &lt;label for="request"&gt; Other Request: &lt;/label&gt;
              &lt;input type="comment" name="request" id="request" placeholder="Other Request"/&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="sub"&gt;
          &lt;p&gt;
              &lt;input type="submit" value="Submit" onclick="msg()" /&gt;
          &lt;/p&gt;
  &lt;/div&gt;
      &lt;?php echo form_close();?&gt;
  </code></pre>
  
  <p>my view page..(whre my edit and delete button show)</p>
  
  <pre><code>       &lt;?php 
     $this-&gt;table-&gt;set_heading("Name","Nationality","Number of Guest","Date of Arrival","Package","Other Request","Delete Record","Edit");
     $qry = $this-&gt;db-&gt;get('booking');
     foreach ($qry-&gt;result() as $row) {
  $this-&gt;table-&gt;add_row($row-&gt;name,$row-&gt;nationality,$row-&gt;number_of_guest,$row-&gt;date,$row-&gt;package,$row-&gt;request,anchor('site/delete/'.$row-&gt;id, 'Del'),anchor('site/update/'.$row-&gt;id, 'edit'));
  
    }
     echo $this-&gt;table-&gt;generate();
  </code></pre>