jQuery Delete Multiple Rows using checkbox PHP with MySQL

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!.

  Laravel redirect route with query string example

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

<div class="container">
<h2>Example: </h2>
<table id="students_grid" class="table table-condensed table-hover table-striped bootgrid-table" width="80%" cellspacing="0">
<thead>
<tr>
<th></th>
<th>Students Name</th>
<th>students_salary</th>
<th>students_age</th>
</tr>
</thead>
<tbody>

<tr id="">
<td><input type="checkbox" class="stud_checkbox" data-stud-id=""></td>
<td></td>
<td></td>
<td></td>
</tr>

</tbody>
</table>
<div class="row">
<div class="col-md-2 well">
<span class="data_row_selected" id="get_chkbox">0 Selected</span>
<a id="delete_records" class="btn btn-primary pull-right">Delete</a>
</div>
</div>
</div>

phases 5: Select All HTML Checkbox using jQuery

<b>row_delete_pro.js</b>
$('#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

  How to Send Emails Using PHP Scripts

$('#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.