На странице просмотра я показываю данные из базы данных в таблице. У меня есть две кнопки в таблице для редактирования и удаления строки. Я хочу удалить определенную строку из базы данных через идентификатор.
просмотр
#
First Name
last name
Email
Edit
Delete
Контроллер
class Welcome extends CI_Controller
{
public function index()
{
$this->load->view('welcome_message', $data);
}
public function register()
{
$this->load->view("register");
}
public function receive()
{
$fname = $this->input->post("fname");
$this->load->model('Model');
$this->Model->insertdata($fname);
// echo $this->input->post("fname");
// echo $this->input->post("lname");
// echo $this->input->post("password");
// echo $this->input->post("Email");
}
public function all_user()
{
$this->load->model('Model');
$data['records'] = $this->Model->get_all_users();
$this->load->view("store_data", $data);
}
public function row_delete()
{
$this->load->model('Model');
$this->mod1->row_delete($id);
redirect($_SERVER['HTTP_REFERER']);
}
}
Модель
class Model extends CI_Model
{
public function insertdata($fname)
{
$data = array(
'fname' => $this->input->post("fname"),
'lname' => $this->input->post("lname"),
'email' => $this->input->post("email"),
'password' => $this->input->post("password"),
);
$this->db->insert('register', $data);
}
public function get_all_users()
{
$query = $this->db->get('register');
return $query->result();
}
public function delete_row()
{
$this->db->where('id', $id);
$this->db->delete('');
}
}