jQuery Delete Multiple Rows using checkbox PHP with MySQL

jQuery Delete Multiple Rows using checkbox PHP with MySQL

In this Post We Will Explain About is jQuery Delete Multiple Rows using checkbox PHP with MySQL With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to delete multiple rows using checkbox in javascriptExample

In this post we will show you Best way to implement how to delete multiple rows using checkbox in jquery, hear for delete multiple records using ajax in phpwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

File Structure

Index.php
remove_pageactions.php
row_delete_pro.js

phases 1: Create simple Database Table

CREATE TABLE IF NOT EXISTS `students` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`students_name` varchar(255) NOT NULL COMMENT 'students name',
`students_salary` double NOT NULL COMMENT 'students salary',
`students_age` int(11) NOT NULL COMMENT 'students age',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

phases 2: Create simple Database Connection

database_db_conect.php


phases 3: Include External Files

index.php






phases 4: Display students Records with all Checkbox and Delete

index.php

Example:

<tr id="">
Students Name students_salary students_age
<input type="checkbox" class="stud_checkbox" data-stud-id="">
0 Selected Delete

phases 5: Select All HTML Checkbox using jQuery

row_delete_pro.js
$('#inp_select_all').on('click', function(e) {
if($(this).is(':checked',true)) {
$(".stud_checkbox").prop('checked', true);
}
else {
$(".stud_checkbox").prop('checked',false);
}

$("#get_chkbox").html($("input.stud_checkbox:checked").length+" Selected");
});

$(".stud_checkbox").on('click', function(e) {
$("#get_chkbox").html($("input.stud_checkbox:checked").length+" Selected");
});

phases 6: Delete All Selected rows with jQuery Ajax

javascript code – Ajax request to remove_pageactions.php

$('#delete_records').on('click', function(e) {
var students = [];
$(".stud_checkbox:checked").each(function() {
students.push($(this).data('stud-id'));
});
if(students.length 1?"these":"this")+" row?";
var checked = confirm(WRN_PROFILE_DELETE);
if(checked == true) {
var selected_values = students.join(",");
$.ajax({
	type: "POST",
	url: "remove_pageactions.php",
	cache:false,
	data: 'stud_id='+selected_values,
	success: function(response) {
	var stud_ids = response.split(",");
	for (var i=0; i < stud_ids.length; i++ ) 
	{ 
		$("#"+stud_ids[i]).remove(); 
	} } 
	}); } } 
});

phases 7: Delete Records from MySQL Database

remove_pageactions.php


Example

I hope you have Got What is Delete Multiple Rows with Checkbox using jQuery, PHP & MySQL And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment