I'm beginner in codeigniter.I'm trying to delete a row from my table.I tried the following code.But it's not working.
This is url i'm passing.
<a href="./Delete_user/<?= $thisid ?>">Delete User</a>
This is my controller (Delete_user.php).
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Delete_user extends CI_Controller {
public function delete_row($id) {
$this->load->model('Delete_selecteduser');
$where = array('id' => $id);
$this->Delete_selecteduser->delete_user('users', $where);
}
And here is my model (Delete_selecteduser.php).
<?php
class Delete_selecteduser extends CI_Model {
public function __construct() {
$this->load->database();
}
public function delete_user($table, $where = array()) {
$this->db->where($where);
$res = $this->db->delete($table);
if ($res)
return TRUE;
else
return FALSE;
}
}
And also I want to display a message that record has been deleted successfully.Please help me to fix this.