title: delete and update specific row in codeigniter
body: <p>I am new in codeigniter.In my view page I am showing the data from database in a table i have two buttons in table to edit and delete the row..I want to delete a specific row from database through id.</p>
  
  <pre><code>## view
  
  
  
  
                      &lt;thead&gt;
                           &lt;tr&gt;
                                &lt;th&gt;#&lt;/th&gt;
                                &lt;th&gt;First Name&lt;/th&gt;
                                &lt;th&gt;last name&lt;/th&gt;
                                 &lt;th&gt;Email&lt;/th&gt;
                           &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                           &lt;?php for ($i = 0; $i &lt; count($records); ++$i) { ?&gt;
                                &lt;tr&gt;
                                     &lt;td&gt;&lt;?php echo ($i+1); ?&gt;&lt;/td&gt;
  
                                     &lt;td&gt;&lt;?php echo $records[$i]-&gt;fname; ?&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;?php echo $records[$i]-&gt;lname; ?&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;?php echo $records[$i]-&gt;email; ?&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;button name="edit"&gt;Edit&lt;/button&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;button name="delete"&gt;Delete&lt;/button&gt;&lt;/td&gt;
                                &lt;/tr&gt;
                           &lt;?php } ?&gt;
                      &lt;/tbody&gt;
  
  
  
  ----------
  ## Controller ##
  
  class Welcome extends CI_Controller {
  
  
      public function index()
      {
  
  
          $this-&gt;load-&gt;view('welcome_message',$data);
      }
      public function register()
       {
          $this-&gt;load-&gt;view("register");
  
       }
      public function receive()
      {
          $fname= $this-&gt;input-&gt;post("fname");
          $this-&gt;load-&gt;model('Model');
          $this-&gt;Model-&gt;insertdata($fname);
          // echo $this-&gt;input-&gt;post("fname");
          // echo $this-&gt;input-&gt;post("lname");
          // echo $this-&gt;input-&gt;post("password");
          // echo $this-&gt;input-&gt;post("Email");
      }
      public function all_user(){
          $this-&gt;load-&gt;model('Model');
           $data['records'] =  $this-&gt;Model-&gt;get_all_users();
          $this-&gt;load-&gt;view("store_data",$data);
  
      }
      public function row_delete(){
  
          $this-&gt;load-&gt;model('Model');
     $this-&gt;mod1-&gt;row_delete($id);
     redirect($_SERVER['HTTP_REFERER']);
      }
  }
  
  
  ----------
  ## Model ##
  
  class Model extends CI_Model{
  
      public function insertdata($fname)
      {
  
  
  
  
   $data = array
  
          ('fname'=&gt; $this-&gt;input-&gt;post("fname"),
  
          'lname' =&gt; $this-&gt;input-&gt;post("lname"),
          'email' =&gt; $this-&gt;input-&gt;post("email"),
          'password' =&gt; $this-&gt;input-&gt;post("password"),
  
  
          );
  
  
      $this-&gt;db-&gt;insert('register',$data);
  
      }
      public function get_all_users()
   {
      $query= $this-&gt;db-&gt;get('register'); 
          return $query-&gt;result();
  
   }
      public function delete_row()
  {$this-&gt;db-&gt;where('id', $id);
  
  $this-&gt;db-&gt;delete(''); 
  
  
      }
  }
  </code></pre>