I can't delete record in Codeigniter
- by jomblo
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