-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_products.php
More file actions
89 lines (77 loc) · 3.18 KB
/
fetch_products.php
File metadata and controls
89 lines (77 loc) · 3.18 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetched Products</title>
<link rel="stylesheet" href="assets/css/fetch.css" />
</head>
<body>
<div class="card">
<div class="card-row">
<div class="cart">
<div class='title'>
<div class='title-row'>
<div class='your-bag'><h4><b>Products</b></h4></div>
</div>
</div>
<div class="main-product-container">
<?php
include './config.php';
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if the link parameter is passed
if(isset($_GET['link'])){
$link = $_GET['link'];
// Query to fetch products based on the unique link
$sql = "SELECT * FROM checkout_products WHERE link = '$link'";
$result = $conn->query($sql);
// Check for errors in query execution
if ($result === false) {
echo "Error executing query: " . mysqli_error($conn);
} else {
// Fetch all rows into an array
$rows = $result->fetch_all(MYSQLI_ASSOC);
// Check if any rows were returned
if (!empty($rows)) {
// Output data of each row
foreach ($rows as $row) {
// Output each product within its own container
echo "
<div class='product-container'>
<div class='img-container'>
<img class='img' src='./admin/product/{$row['productImage']}'>
</div>
<div class='product-name'>
<div class='keys'>
<div class='pname'>{$row['productName']}</div>
</div>
</div>
<div class='price-container'>
<div class='row upprice' data-price='{$row['productPrice']}'>
<span class='row total-price'>Price: ₦ {$row['productPrice']}</span>
</div>
<div class='big-price'>₦ {$row['productPrice2']}</div>
</div>
</div>";
}
} else {
echo "No products found for this link.";
}
}
} else {
echo "Invalid link.";
}
$conn->close();
?>
</div>
<div class="back-to-shop">
<a href="./index.php">← <span class="text-muted">Back to Home</span></a>
</div>
</div>
</div>
</div>
</body>
</html>