CodeIgniter Tutorial: How To Delete Data From Database Using CodeIgniter

This video learn how to delete data from database using CodeIgniter.



Watch Related Video
https://www.youtube.com/watch?v=AuQ3e8qvu18

Add Function "delete_student_id" in manage_student.php (Controllers)

//This is delete function. I created function name is delete_student_id have one parameter is $studentid

function delete_student_id($studentid) {
//this function call to del_student_id method in file manage_student_model
$this->manage_student_model->del_student_id($studentid);
//This is status to show when you delete it ready
echo 'You have been delete this student.<br><a href=http://localhost/student/manage_student/>Go Back</a>';
}

Add Function "del_student_id" in manage_student_model.php (Models)

//This function is important
//function to Delete selected record from table name students

function del_student_id($studentid){
        //Where studentid=$studentid is parameter get value from controller manage_student
        $this->db->where('studentid', $studentid);
        //delete from table students and then update to database
$this->db->delete('students');   

}

Add this code to routers.php

$route['student/delete/(:any)'] = 'manage_student/delete_student_id/$1';

Demo
http://downloads.ziddu.com/download/24360486/student.zip.html

Read more blog:
http://video-tutorial-from-youtube.blogspot.com/

Follow Us with Facebook
https://www.facebook.com/pages/PHP-Tutorial/782239958529506

Share this

Related Posts

Previous
Next Post »