PHP
OOPs
JavaScript
JQuery
Ajax
Codeigniter
Laravel
MySql
Node.js
Tutorials
C
C++
Json
Codeigniter 4
htaccess
wordpress
react.js
Blogs
Fundamental
Python
Search Your Query
×
--- Select Category ---
PHP
OOPs
JavaScript
JQuery
Ajax
Codeigniter
Laravel
MySql
Node.js
Tutorials
Blogs
Fundamental
Python
Most Popular Tutorials
What is php?
How to install php?
How to write program in php?
what is variable?
Variable handling function in php
Variable scope
PHP Constant
DataType
PHP Operators
PHP Comments
php If else statements
PHP Loop
Continue and Break
switch statement
Typecasting
Types of errors in php
Function
Date Function
Header function
php inbuilt function
unlink & unset
what is filter_var() function in php?
ob_start
htmlspecialchars() and htmlentities()
array
Array Short function
Array Function
String
String function
Get & Post methods
include and require
implode and explode function
Cookies
Session
File uploading in php
File Handling
File Handling Functions
Exception
PHP GD Library (Images)
Curl
Encription and Decription
SQL injection
Security for website
Captcha
Server variable
Insert Data using Ajax
View Data Using Ajax
Update Data Using Ajax
Delete Data Using Ajax
serialize method using Ajax
Upload Data using Ajax
Check username availability using ajax
Check duplicate email using ajax
Delete multiple data using ajax with checkbox
Ckeditor Using Ajax
Show loading image using Ajax
301 and 302 Redirect Page
Number format function
url rewriting using htaccess
Google map
PHP Programs
Login, Registration and Logout application
CRUD in php
CRUD with Procedure
Trigger
PHP Interview Questions
Tutorials Menus
What is php?
How to install php?
How to write program in php?
what is variable?
Variable handling function in php
Variable scope
PHP Constant
DataType
PHP Operators
PHP Comments
php If else statements
PHP Loop
Continue and Break
switch statement
Typecasting
Types of errors in php
Function
Date Function
Header function
php inbuilt function
unlink & unset
what is filter_var() function in php?
ob_start
htmlspecialchars() and htmlentities()
array
Array Short function
Array Function
String
String function
Get & Post methods
include and require
implode and explode function
Cookies
Session
File uploading in php
File Handling
File Handling Functions
Exception
PHP GD Library (Images)
Curl
Encription and Decription
SQL injection
Security for website
Captcha
Server variable
Insert Data using Ajax
View Data Using Ajax
Update Data Using Ajax
Delete Data Using Ajax
serialize method using Ajax
Upload Data using Ajax
Check username availability using ajax
Check duplicate email using ajax
Delete multiple data using ajax with checkbox
Ckeditor Using Ajax
Show loading image using Ajax
301 and 302 Redirect Page
Number format function
url rewriting using htaccess
Google map
PHP Programs
Login, Registration and Logout application
CRUD in php
CRUD with Procedure
Trigger
PHP Interview Questions
Share On Facebook
How to delete multiple data using ajax with checkbox?
File Name : index.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>View Ajax</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>View data</h2>
<table class="table table-bordered table-sm" >
<thead>
<tr>
<th><input type="checkbox" id="select_all"> Select </th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>City</th>
<th>Action</th>
</tr>
</thead>
<tbody id="table">
</tbody>
</table>
<div class="row">
<div class="col-md-2 well">
<span class="rows_selected" id="select_count">0 Selected</span>
<a type="button" id="delete_records" class="btn btn-primary pull-right">Delete</a>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$.ajax({
url: "View_ajax.php",
type: "POST",
cache: false,
success: function(dataResult){
$('#table').html(dataResult);
}
});
/* delete selected records*/
$('#delete_records').on('click', function(e) {
var employee = [];
$(".emp_checkbox:checked").each(function() {
employee.push($(this).data('emp-id'));
});
if(employee.length <=0) {
alert("Please select records.");
}
else {
WRN_PROFILE_DELETE = "Are you sure you want to delete "+(employee.length>1?"these":"this")+" row?";
var checked = confirm(WRN_PROFILE_DELETE);
if(checked == true) {
var selected_values = employee.join(",");
$.ajax({
type: "POST",
url: "delete_ajax.php",
cache:false,
data: 'id='+selected_values,
success: function(response) {
/* remove deleted employee rows*/
var ids = response.split(",");
for (var i=0; i < ids.length; i++ ) {
$("#"+ids[i]).remove();
}
}
});
}
}
});
});
$(document).on('click', '#select_all', function() {
$(".emp_checkbox").prop("checked", this.checked);
$("#select_count").html($("input.emp_checkbox:checked").length+" Selected");
});
$(document).on('click', '.emp_checkbox', function() {
if ($('.emp_checkbox:checked').length == $('.emp_checkbox').length) {
$('#select_all').prop('checked', true);
} else {
$('#select_all').prop('checked', false);
}
$("#select_count").html($("input.emp_checkbox:checked").length+" Selected");
});
</script>
</body>
</html>
File Name : view_ajax.php
<?php
include 'database.php';
$sql = "SELECT * FROM crud";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<tr id="<?php echo $row["id"]; ?>">
<td><input type="checkbox" class="emp_checkbox" data-emp-id="<?php echo $row["id"]; ?>"></td>
<td><?=$row['name'];?></td>
<td><?=$row['email'];?></td>
<td><?=$row['phone'];?></td>
<td><?=$row['city'];?></td>
<td><button type="button" class="btn btn-success btn-sm delete" data-id="<?=$row['id'];?>">Delete</button></td>
</tr>
<?php
}
}
else {
echo "<tr >
<td colspan='5'>No Result found !</td>
</tr>";
}
mysqli_close($conn);
?>
delete
File Name : delete_ajax.php
<?php
include 'database.php';
if(isset($_POST['id'])) {
$id = trim($_POST['id']);
$sql = "DELETE FROM crud WHERE id in ($id)";
if(mysqli_query($conn, $sql)){
echo $id;
}
}
?>
Share On Facebook
Previous
Next
Trending Tutorials
PHP
100+ Tutorials
PHP OOPs
80+ Tutorial
Codeigniter
100+ Tutorial
Laravel
100+ Tutorials
NODE.JS
100+ Tutorials
Javascript
100+ Tutorials
Download Live Projects
Review & Rating
0.0
/ 5
0
Review
5
(
0
)
4
(
0
)
3
(
0
)
2
(
0
)
1
(
0
)
Write Review Here
Review
Submit Review
×
Submit
Ittutorial
Ittutorial
Most Popular Tutorials
File Handling Functions
Number format function
ob_start
PHP Operators
Delete Data Using Ajax
Variable handling function in php
Variable scope
Encription and Decription
Continue and Break
Date Function
Array Function
Upload Data using Ajax
PHP Comments
Check duplicate email using ajax
View Data Using Ajax
implode and explode function
PHP Constant
String function
Session
php inbuilt function
Important Link
Core php Online Advance Tutorails and video Tutorials.
How to manage Session in php Tutorials.
More .......
upcomming codeigniter and angular js tutorials.
Click here to see More ...
Hello Friend Please Follow & Share Ittutorial.
×
Ittutorial
Please Follow and Share ittutorial.
Ittutorial