This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
product-list.php
70 lines (63 loc) · 2.31 KB
/
product-list.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
<?php
$conn = require_once("connection/connection.php");
try {
$sql = "select * from product order by productID desc";
$stmt = $conn->prepare($sql);
$stmt->execute();
} catch (PDOException $ex) {
echo "Error: " . $ex->getMessage();
}
?>
<!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">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" rel="stylesheet">
<title>Product List</title>
</head>
<body>
<div class="container mt-4">
<p>
<h2>Product list</h2></p>
<p><a href="product-add.php" title="add new product" class="btn btn-outline-primary">Add product</a></p>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Product Name</th>
<th>Price</th>
<th>Image</th>
<th>Category</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php while ($row = $stmt->fetch()) { ?>
<tr>
<td><?= $row['productID'] ?></td>
<td><?= $row['productName'] ?></td>
<td><?= $row['productPrice'] ?></td>
<td>
<a href="" title=" <?= $row['productDetails'] ?>">
<img src="images/product/<?= $row['productImage'] ?>" alt=" no image" height="120px"
width="120px">
</a>
</td>
<td><?= $row['categoryID'] ?></td>
<td>
<a href="product-edit.php?id=<?= $row['productID'] ?>" title="edit this product"><i
class="fa-solid fa-pen"></i></a>
<a href="product-delete.php?id=<?= $row['productID'] ?>" title="delete this product"
onclick="confirm('are you sure?');"><i class="fa-solid fa-trash"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</body>
</html>