New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home php codes delete multiple records using checkbox php

delete multiple records using checkbox php

delete multiple records using checkbox php

Welcome back to, in our previous post we learn How to Create pagination using php and mysql . now in this post we will learn how to delete multiple records using checkbox with the help of PHP and MySQL.

delete multiple records in PHP

before start this tutorial first of all we should understand the overall scenario of this post.
now first of all we need to create a database connection , so in this example my database name is testdb .

after creating a database connection we fetch all the records from our user table and designed it in a tabular format with checkbox field, and also create a java script function that will help us to select all check boxes at a time.
so just follow the below code.

Also Read :
Get Domain name from URL
Unable to create a directory a wordpress error
How to Send Attachment on mail using PHP.
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

$conn = mysqli_connect("localhost","root","rootroot","testdb");
	$checkbox = $_POST['check'];
	$del_id = $checkbox[$i]; 
	mysqli_query($conn,"DELETE FROM user WHERE id='".$del_id."'");
	$message = "Data deleted successfully !";
$result = mysqli_query($conn,"SELECT * FROM user");
<!DOCTYPE html>
<link rel="stylesheet" href="">
<script src=""></script>
<title>Delete userandroid data</title>
<div><?php if(isset($message)) { echo $message; } ?>
<form method="post" action="">
<table class="table table-bordered">
    <th><input type="checkbox" id="checkAl"> Select All</th>
	<th>userandroid Id</th>
	<th>First Name</th>
	<th>Email id</th>
while($row = mysqli_fetch_array($result)) {
    <td><input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["id"]; ?>"></td>
	<td><?php echo $row["id"]; ?></td>
	<td><?php echo $row["user_name"]; ?></td>
	<td><?php echo $row["email"]; ?></td>
<p align="center"><button type="submit" class="btn btn-success" name="save">DELETE</button></p>
$("#checkAl").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);

copy the above code and save it on htdocs directory of your xampp server.
there is a www folder if you are using WAMP or Appserv local server.

share this code with your developer buddies and if you have another way to make it simple ,please feel free to contact we will update your method also in this post.

keep coding, keep learning