-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprodutos.php
66 lines (58 loc) · 2.37 KB
/
produtos.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
<?php include 'config.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Produtos</title>
<link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/produtos.css">
<script src="js/general.js" defer></script>
</head>
<body>
<?php include 'nav.php'; ?>
<section class="all-products">
<h3>Produtos</h3>
<div class="products">
<?php
$conn = new mysqli($GLOBALS['sql_host'], $GLOBALS['sql_user'], $GLOBALS['sql_pass'], $GLOBALS['sql_db']);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
/* PRODUTO */
$sql = "SELECT * FROM `produtos`;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<div class="product" product-id="<?php echo $row['id']; ?>">
<div class="product-image"
style="background-image: url('<?php echo $row['img_dir']; ?>');">
</div>
<div class="product-info">
<div class="product-title">
<div class="product-name">
<p><?php echo $row['name']; ?></p>
</div>
<p class="product-price">R$ <?php echo str_replace(".", ",", strval($row["price"]))?></p>
</div>
<div class="product-description">
<p><?php echo $row['description']; ?></p>
</div>
</div>
</div>
<?php
}
} else {
$conn->close();
return;
}
$conn->close();
?>
</div>
</section>
<footer class="footer">
<span class="js-year">2023</span> © Todos os Direitos Reservados a Confeitaria | Imagens meramente ilustrativas.
</footer>
</body>
</html>