-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.php
52 lines (48 loc) · 1.46 KB
/
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
<!DOCTYPE html>
<html>
<head>
<title>Product Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav>
<ul>
<li><a href="dashboard.php">Home</a></li>
<li><a href="product.php">Products</a></li>
<li><a href="orders.php">Orders</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</nav>
<div class="container">
<h1>Products</h1>
<form method="post" action="payment.php">
<?php
// Connect to the database
include('dbconnect.php');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Select all products from the products table
$sql = "SELECT * FROM products";
$result = mysqli_query($conn, $sql);
// Display all products in a scrollable list
while($row = mysqli_fetch_assoc($result)) {
echo '<div class="product">';
echo '<img src="' . $row['image'] . '">';
echo '<h2>' . $row['name'] . '</h2>';
echo '<p>' . $row['description'] . '</p>';
echo '<p>$' . $row['price'] . '</p>';
echo '<p>$' . $row['available'] . '</p>';
echo '<input type="number" min="1" name="quantity[' . $row['id'] . ']" value="1">';
echo '<input type="radio" name="selected_product" value="' . $row['id'] . '">';
echo '</div>';
}
// Close the database connection
mysqli_close($conn);
?>
<button type="submit" name="submit">Proceed to Payment</button>
</form>
</div>
</body>
</html>