I can't delete record in Codeigniter

Posted by jomblo on Stack Overflow See other posts from Stack Overflow or by jomblo
Published on 2013-10-24T19:59:25Z Indexed on 2013/10/28 21:54 UTC
Read the original article Hit count: 155

Filed under:
|
|

I'm learning CRUD in codeigniter. I have table name "posting" and the coloumns are like this (id, title, post). I successed to create a new post (both insert into database and display in the view). But I have problem when I delete my post in the front-end. Here is my code:

Model

Class Post_Model extends CI_Model{
  function index(){
     //Here is my homepage code
  }

  function delete_post($id)
  {
     $this->db->where('id', $id);
     $this->db->delete('posting');
  }
}

Controller

Class Post extends CI_Controller{
  function delete()
  {
     $this->load->model('Post_Model');
     $this->Post_Model->delete_post("id");

     redirect('Post/index/', 'refresh');
  }
}

After click "delete" in the homepage, there was nothing happens. While I'm looking into my database, my records still available.

Note: (1) to delete record, I'm following the codeigniter manual / user guide, (2) I found a message error (Undefined variable: id) after hiting the "delete" button in the front-end

Any help or suggestion, please

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql