Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Site Map

XpertPhp

Expertphp Is The Best Tutorial For Beginners

  • Home
  • Javascript
    • Jquery
    • React JS
    • Angularjs
    • Angular
    • Nodejs
  • Codeigniter
  • Laravel
  • Contact Us
  • About Us
  • Live Demos
Delete A Multiple Selected Rows In PHP Without Ajax

delete a multiple selected rows in PHP without Ajax

Posted on March 24, 2019June 9, 2020 By XpertPhp No Comments on delete a multiple selected rows in PHP without Ajax

In this post, we have shared How To delete multiple selected rows in PHP without Ajax. normally we have added the button or anchor tag for delete single data. but when we have large data and we will delete the single data, at that time it will take more time. Then at that time, this functionality will helpful.

For discussion, How To delete multiple selected rows in PHP without Ajax. after then configuration database and fetch the data and also we will have set bootstrap and take the form and table. here pass data into TR and TD tag through ‘WHILE’ loop and also take checkbox with multiple names in every single row.

When we will have checked the checkbox and then after click on the delete button then the form will be submitted. it will count the number of checkboxes that are checked. it will get the checkbox value using the for a loop after then delete data one by one.

See below an example of How To delete multiple selected rows in PHP without Ajax.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
$hostname="localhost";
$username="root";
$password="";
$database="php";
$conn = mysqli_connect($hostname,$username,$password,$database);
if(isset($_POST['btnDelete']))
{
$checkbox = $_POST['check'];
for($i=0;$i<count($checkbox);$i++)
{
$del_id = $checkbox[$i];
mysqli_query($conn,"delete from users where id='".$del_id."'");
$message = "Data Successfully Deleted";
}
}
$result = mysqli_query($conn,"select * from users");
?>
<!DOCTYPE html>
<html>
<head>
<title>How To delete a multiple selected rows in PHP without 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/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12">
<?php if(isset($message)) { ?>
<div class="alert alert-success alert-dismissible">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Success!</strong> <?php echo $message; ?> </strong>
</div>
<?php } ?>
</div>
</div>
 
<form method="post" action="">
<div class="row">
<div class="col-lg-12">
<button type="submit" class="btn btn-danger btn-sm" name="btnDelete">DELETE</button>
</div>
</div>
<br/>
<table class="table table-bordered">
<thead>
<tr>
<th><input type="checkbox" id="checkAll"> <label for="checkAll">Select All</label></th>
<th>Id</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Created Date</th>
</tr>
</thead>
<?php
$i=0;
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["id"]; ?>"></td>
<td><?php echo $row["id"]; ?></td>
<td><?php echo $row["first_name"]; ?></td>
<td><?php echo $row["last_name"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td><?php echo $row["created"]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</form>
</div>
<script>
$("#checkAll").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
</script>
</body>
</html>

I have shared demo Button or URL. So you can click on Button or URL and show the demo.

Show Demo

Please follow and like us:
error
fb-share-icon
Tweet
fb-share-icon

Recommended Posts:

  • CodeIgniter join query example
  • laravel eloquent WhereNotBetween query example
  • How to Convert Date and Time from one timezone to another in php
  • How to fixed header part on scrolling sticky menu
  • upload a file with JavaScript and PHP
Jquery, MySql, Php Tags:delete multiple rows, delete selected rows, jquery tutorial, php with mysql

Post navigation

Previous Post: How to change the date formate in php
Next Post: Jquery autocomplete search using php mysql and ajax

Categories

  • Ajax
  • Angular
  • Angularjs
  • Bootstrap
  • Codeigniter
  • Css
  • Htaccess
  • Javascript
  • Jquery
  • Laravel
  • MongoDB
  • MySql
  • Nodejs
  • Php
  • React JS
  • Shopify Api
  • Ubuntu

Tags

angular 10 tutorial angular 11 ci tutorial codeigniter 4 image upload Codeigniter 4 Tutorial codeigniter tutorial CodeIgniter tutorial for beginners codeigniter with mysql crud operation eloquent relationships file upload File Validation form validation Image Upload jQuery Ajax Form Handling jquery tricks jquery tutorial laravel 6 Laravel 6 Eloquent Laravel 6 Model laravel 6 relationship laravel 6 relationship eloquent Laravel 6 Routing laravel 7 Laravel 7 Eloquent laravel 7 routing laravel 7 tutorial Laravel 8 laravel 8 example laravel 8 tutorial laravel 9 example laravel 9 tutorial Laravel Framework laravel from scratch Laravel Socialite laravel social login nodejs pagination payment gateway php with mysql react js tutorial rewrite rule send mail validation wysiwyg editor

Latest Posts

  • How to Convert Date and Time from one timezone to another in php
  • how to get current date and time in php
  • Drag and Drop Reorder Items with jQuery, PHP & MySQL
  • Laravel 9 Toastr Notifications Example Tutorial
  • Laravel 9 CRUD Operation Example Using Google Firebase
  • Laravel 9 CKeditor Image Upload With Example
  • Laravel 9 Summernote Image Upload With Example
  • Laravel 9 Stripe Payment Gateway Integrate Example
  • How To Send Email Using Mailtrap In Laravel 9
  • Laravel 9 Fullcalendar Ajax Example Tutorial

Tools

  • Compound Interest Calculator
  • Hex to RGB Color Converter
  • Pinterest Video Downloader
  • Age Calculator Online
  • Convert JSON to PHP Array Online
  • JavaScript Minifier
  • CSS Beautifier
  • CSS Minifier
  • JSON Beautifier
  • JSON Minifier

Copyright © 2018 - 2022,

All Rights Reserved Powered by XpertPhp.com