How to delete data From database Using CodeIgniter?

How to delete data From database Using CodeIgniter?
Faisal Khan
Asked 08-05-2020
75

Answer (1)
Use follow code for delete operation in CodeIgniter. StudentController class function delete_student(){ $student_id = $this->input->get("studentId"); $result = $this->StudentModel->delete_student($student_id); if($result) redirect(base_url."StudentController/studentlist"); } StudentModel class //function to Delete selected record from table name students function delete_student($id){ $this->db->where("student_id", $id); $this->db->delete("students"); if($this->db->affected_rows()){ return true; } } }
Ankur Rajput
Asked 20-07-2018
45 Likes
Comments
Write comment

Submit your answer