-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeletion.php
42 lines (33 loc) · 1.06 KB
/
Deletion.php
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
<?php
require('mysql.php');
$size = sizeof($_POST); //that is size of elements inputted for deletion
$j = 1;
for ($i = 1; $i <= $size; $i++,$j++) {
$index = "b".$j; //'b' holding value of elements which have to be delete see DeletForm.php
if (isset($_POST[$index])) { //isset() retuns true(if index selected by user to delete) or false(not selected by user to delete)
$id[$i] = $_POST[$index];
//creating an array $id[$i] which will be hold value of $_POST[$index]=b1=1(in first condition if it true) means this array will contain all that values which are user want to delete else decreament $i,
} else {
$i--;
}
}
for ($k = 1; $k <= $size; $k++ ) {
$q = "delete from Book Where B_ID =".$id[$k];
mysqli_query($conn, $q);
}
mysqli_close($con);
?>
<!DOCTYPE html>
<html>
<head>
<title> Deletion </title>
</head>
<body>
<h1> Book Record Management </h1>
<p> <?php
echo $size." Records Deleted";
?>
</p>
Go Back to Home Page <a href="index.php">Click Here</a> <!-- Aunchor tag -->
</body>
</html>