-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
59 lines (50 loc) · 1.94 KB
/
index.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
<?php
include 'config/db_connect.php';
//query to get all items list
$query = "SELECT * from items ORDER BY created_at";
//getting data
$result = mysqli_query($connection, $query);
//fetching data in as an array
$items = mysqli_fetch_all($result, MYSQLI_ASSOC);
//free result from memory
mysqli_free_result($result);
//closing the connection
mysqli_close($connection);
//end
session_start();
$success = $_SESSION['success'] ?? '';
?>
<!DOCTYPE html>
<html lang="en">
<?php include 'layouts/header.php'; ?>
<h4 class="center">Items</h4>
<div class="container">
<div class="green center"><?php echo htmlspecialchars($success); ?></div>
<div class="row">
<?php foreach ($items as $key => $item): ?>
<div class="col s6 md3">
<div class="card z-depth-0">
<img src="images/product.png" class="item" alt="<?php echo $item['item_name']; ?>">
<div class="card-content center">
<h6><?php echo htmlspecialchars($item['item_name']); ?></h6>
<div>₹ <?php echo htmlspecialchars($item['item_price']) ?></div>
<div>
<?php $tags = explode(',', $item['item_tags']); ?>
<ul>
<?php foreach($tags as $tag): ?>
<li><?php echo htmlspecialchars($tag); ?></li>
<?php endforeach; ?>
</ul>
</div>
<p><?php echo htmlspecialchars($item['description']) ?></p>
</div>
<div class="card-action right-align">
<a class="brand-text" href="item-details.php?id=<?php echo $item['id']; ?>">more info</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php include 'layouts/footer.php'; ?>
</html>