forked from Zilleali/Easyfourr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.php
More file actions
70 lines (61 loc) · 1.52 KB
/
dev.php
File metadata and controls
70 lines (61 loc) · 1.52 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
<?php
// Connect to the database
$host = 'localhost';
$user = 'root';
$password = '';
$database = 'ecomm';
$connection = mysqli_connect($host, $user, $password, $database);
// Check for errors
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
?>
<?php
// Retrieve the category data
$query = "SELECT * FROM category";
$result = mysqli_query($connection, $query);
// Check for errors
if (!$result) {
echo "Failed to retrieve categories: " . mysqli_error($connection);
exit();
}
?>
<!-- CSS for the card layout -->
<style>
.card {
width: 300px;
border: 1px solid #ccc;
margin: 10px;
padding: 10px;
float: left;
box-sizing: border-box;
}
.card img {
width: 100%;
height: 200px;
object-fit: cover;
margin-bottom: 10px;
}
.card h3 {
margin: 0;
}
.card p {
margin: 10px 0;
}
.clearfix {
clear: both;
}
</style>
<!-- HTML for the card layout and product data -->
<div class="cards">
<?php while ($product = mysqli_fetch_assoc($result)): ?>
<div class="card">
<!-- <img src="<?php echo $product['image_url']; ?>" alt="<?php echo $product['name']; ?>"> -->
<h3><?php echo $product['name']; ?></h3>
<!-- <p><?php echo $product['description']; ?></p>
<p>Price: <?php echo $product['price']; ?></p> -->
</div>
<?php endwhile; ?>
<div class="clearfix"></div>
</div>