title: How to edit data in a database in with codeigniter
body: <p>I want to know how I go about selecting a voter in the database table and edit the information with a form in Codeigniter. I already created a search table for it and will post the code below.</p>
  
  <p>Model:</p>
  
  <pre><code>public function search_voters($search_term){
     $this-&gt;db-&gt;select('*');
     $this-&gt;db-&gt;from('voterinfo');
     $this-&gt;db-&gt;like('firstName', $search_term['firstName']);
     $this-&gt;db-&gt;like('lastName', $search_term['lastName']);
     $this-&gt;db-&gt;like('street', $search_term['street']);
     $this-&gt;db-&gt;like('dob', $search_term['dob']);
     $query = $this-&gt;db-&gt;get();
     return $query-&gt;result_array();
  
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function search(){
      $this-&gt;load-&gt;model('reg_model');
  
      $search_term = array(
      'firstName' =&gt; $this-&gt;input-&gt;post('firstName'),
      'lastName' =&gt; $this-&gt;input-&gt;post('lastName'),
      'street' =&gt; $this-&gt;input-&gt;post('street'),
      'dob' =&gt; $this-&gt;input-&gt;post('dob')
          );
  
  
      $data['query'] = $this-&gt;reg_model-&gt;search_voters($search_term);
  
  
      $this-&gt;load-&gt;view("reg_header");
      $this-&gt;load-&gt;view("reg_nav");
      $this-&gt;load-&gt;view("reg_search", $data); 
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>echo form_open("reg/search");
  
  echo form_label("First Name: ", "firstName");
  
  $data = array(
      "name" =&gt; "firstName",
      "id" =&gt; "firstName",
      "value" =&gt; set_value("firstName")
  );    
  echo form_input($data);
  
  //last name
  echo form_label("Last Name: ", "lastName");
  
  $data = array(
      "name" =&gt; "lastName",
      "id" =&gt; "lastName",
      "value" =&gt; set_value("lastName")
  );    
  echo form_input($data);
  
  echo form_label("Street: ", "street");
  
  $data = array(
      "name" =&gt; "street",
      "id" =&gt; "street",
      "value" =&gt; set_value("street")
  );    
  echo form_input($data);
  
  echo form_label("Date of Birth: ", "dob");
  
  $data = array(
      "name" =&gt; "dob",
      "id" =&gt; "dob",
      "value" =&gt; set_value("dob")
  );    
  echo form_input($data);
  
  echo form_submit("searchSubmit", "Search");
  
  echo form_close();
  
  
  
  
  $this-&gt;table-&gt;set_heading(array('', 'Voter Number', 'First Name', 'Last Name',
                                  'mid Initial', 'Home Number', 'Street',
                                  'Apt', 'Zip', 'DOB',
                                  'Local District', 'State District'));
  
  foreach ($query as $row){
  
      $this-&gt;table-&gt;add_row($row);       
  }
  
  echo $this-&gt;table-&gt;generate();
  </code></pre>
  
  <p><strong>Update</strong>
  I've been working on this and came up with something but I am still having issues
  Updated View:</p>
  
  <pre><code>foreach ($query as $row){
      $this-&gt;table-&gt;add_row(anchor('reg/view_form/' ,  $row, 'title="VoterNum"'), $row);
  
  }
  echo $this-&gt;table-&gt;generate();
  </code></pre>