-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminProduct.php
136 lines (120 loc) · 4.66 KB
/
adminProduct.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
<?php
//Tell PHP to log errors
ini_set('log_errors', 'On');
//Tell PHP to not display errors
ini_set('display_errors', 'Off');
//Set error_reporting to E_ALL
ini_set('error_reporting', E_ALL );
include '_dbConnect.php';
// Start the session
session_start();
if($_SESSION["delete"])
{
$_SESSION["delete"] = false;
echo '<div class="alert text-center alert-success alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
Product Removed Successfully!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if(!$_SESSION["delete"] && $_SESSION["deleteAlert"])
{
$_SESSION["deleteAlert"] = false;
echo '<div class="alert text-center alert-danger alert-dismissible fade show mb-0" role="alert" style="z-index:1000">
<strong>Error!</strong> Product not found.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if($_SESSION["add"])
{
$_SESSION["add"] = false;
echo '<div class="alert text-center alert-success alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
Product Added Successfully!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if(!$_SESSION["add"] && $_SESSION["addAlert"])
{
$_SESSION["addAlert"] = false;
echo '<div class="alert text-center alert-danger alert-dismissible fade show mb-0" role="alert" style="z-index:1000">
<strong>Error!</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Tab Icon -->
<link rel="icon" href="assests/images/logo.png" type="image/icon type">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
<title>Product Gallery</title>
</head>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&family=Roboto+Slab:wght@500&display=swap');
*{
font-family: "roboto slab";
}
table,
th,
td {
padding: 10px;
border: 1px solid black;
border-collapse: collapse;
}
a {
text-decoration: none;
}
</style>
<body>
<table class="mx-3 my-3">
<tr>
<td class="text-center" colspan="11"><a href="admin.php" style="font-size:3rem; color:rgb(85,150,162); text-decoration:none;">BookStore®</a></td>
</tr>
<tr>
<th class="text-center">Id</th>
<th class="text-center">Product Name</th>
<th class="text-center">Price</th>
<th class="text-center">Discount</th>
<th class="text-center">Description</th>
<th class="text-center">Category</th>
<th class="text-center">Image</th>
<th class="text-center">Availability</th>
<th class="text-center">Tags</th>
<th class="text-center">Rating</th>
<th class="text-center">Product</th>
<th> </th>
</tr>
<?php
$sql = "Select * from products";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)):
?>
<tr>
<td class="text-center"><?= $row["pid"] ?></td>
<td class="text-center"><?= strtoupper($row["pname"]) ?></td>
<td class="text-center">$ <?= number_format($row["pprice"],2) ?>/-</td>
<td class="text-center"><?= $row["offer"] ?>%</td>
<td class="text-center"><?= $row["description"] ?></td>
<td class="text-center"><?= $row["category"] ?></td>
<td class="text-center"><img src="<?= $row["photo"] ?>" alt="product image" style="width:80%"></td>
<td class="text-center"><?= $row["availability"] ?></td>
<td class="text-center"><?= $row["tag"] ?></td>
<td class="text-center"><?= $row["rating"] ?></td>
<td class="text-center"><?= ucwords($row["nf"]) ?></td>
<td class="text-center"><a href="adminRemove.php?id=<?= $row["pid"] ?>" class="text-danger" onclick="return confirm('Are you sure want to remove this product?');"> <i class="fas fa-trash-alt"></i> </a></td>
</tr>
<?php endwhile; ?>
</table>
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"
crossorigin="anonymous"></script>
</body>
</html>