-
Notifications
You must be signed in to change notification settings - Fork 1
/
remove_product.php
142 lines (130 loc) · 6.09 KB
/
remove_product.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
include 'includes/common.php';
if (!(isset($_SESSION["email"]) && $_SESSION["email"] == "[email protected]")) {
header('location: index.php');
}
if (isset($_POST['remove'])) {
$id = $_POST['remove'];
$query = "DELETE FROM products WHERE id='$id'";
$result = mysqli_query($con, $query) or die($mysqli_error($con));
?>
<script>
window.alert("Product Deleted");
</script>
<?php
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Super Market - Remove Product</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/home.css">
<script type="text/javascript" src="bootstrap/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<?php include 'includes/login-navbar.php' ?>
<div class="container">
<?php
if (!isset($_GET['category'])) {
?>
<h2 class="text-center fw-bolder text-decoration-underline mt-5 mb-3">Remove Products</h2>
<div class="row">
<?php
$query = "SELECT * FROM products";
$result = mysqli_query($con, $query) or die($mysqli_error($con));
$num = mysqli_num_rows($result);
if ($num == 0) {
?>
<script>
window.alert("No Products Found");
location.href = "remove_product.php";
</script>
<?php
}
while ($row = mysqli_fetch_array($result)) {
?>
<div class="col-md-4 col-6 col-xl-3 col-sm-6 mb-4 mt-4 col-xxl-2">
<div class="card" style="width: 100%; ">
<img src="<?php echo $row['img_path'] ?>" class="card-img-top" alt="..." style="width: 100%; height: 129px; object-fit: fill;">
<div class="card-body">
<p class="card-title fw-bold mb-0 pb-0"><?php echo $row['name']; ?></p>
<div class="mt-0 pt-0">
<p class="m-0 p-0"><?php echo $row['category']; ?></p>
<p class="m-0 p-0"><?php echo $row['brand']; ?></p>
<p class="m-0 p-0"> Price : ₹<?php echo $row['price']; ?></p>
</div>
<hr>
<form class="d-grid gap-3" action="remove_product.php" method="POST" id="removeproduct">
<button form="removeproduct" type="submit" name="remove" value="<?php echo $row['id']; ?>" class="btn btn-outline-danger">Remove</button>
</form>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<h2 class="text-center fw-bolder text-decoration-underline mt-5 mb-3"><?php echo $_GET['category']; ?></h2>
<div class="row">
<?php
$category = $_GET['category'];
$query = "SELECT * FROM products WHERE category='$category'";
$result = mysqli_query($con, $query) or die($mysqli_error($con));
$num = mysqli_num_rows($result);
if ($num == 0) {
?>
<script>
window.alert("No Products Found");
location.href = "remove_product.php";
</script>
<?php
}
while ($row = mysqli_fetch_array($result)) {
?>
<div class="col-md-4 col-6 col-xl-3 col-sm-6 mb-4 mt-4 col-xxl-2">
<div class="card" style="width: 100%; ">
<img src="<?php echo $row['img_path'] ?>" class="card-img-top" alt="..." style="width: 100%; height: 129px; object-fit: fillr;">
<div class="card-body">
<p class="card-title fw-bold mb-0 pb-0"><?php echo $row['name']; ?></p>
<div class="mt-0 pt-0">
<p class="m-0 p-0"><?php echo $row['category']; ?></p>
<p class="m-0 p-0"><?php echo $row['brand']; ?></p>
<p class="m-0 p-0"> Price : ₹<?php echo $row['price']; ?></p>
</div>
<hr>
<div class="d-grid gap-3">
<button class="btn btn-outline-danger">Remove</button>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
}
if ($num < 7) {
?>
<div class="row justify-content-center align-items-center" style="height: 19.2vh;"></div>
<?php
}
if (isset($_GET["error"])) {
echo $_GET['error'];
}
?>
</div>
<?php include 'includes/login-footer.php' ?>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz" crossorigin="anonymous"></script>
</body>
</html>