-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
30 lines (29 loc) · 1.2 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
<?php
require_once 'header.php';
$id = $_GET['id'];
$dbh = connectDB();
$connexion = $dbh->prepare('SELECT * from products where id = :id');
$connexion->execute([
":id" => $id,
]);
$results = $connexion->fetchAll();
$dbh = connectDB();
$connexion = $dbh->prepare('SELECT products.category_id, categories.name, categories.parent_id from products left join categories ON products.category_id = categories.parent_id');
$connexion->execute();
$resultstype = $connexion->fetchAll();
?>
<?php foreach ($results as $result => $resultproduct) {
$resulttype = $resultstype[$result]; ?>
<div class='card mx-auto'>
<div class='card-body'>
<img src="<?= $resultproduct['img'] ?>" class='card-img-top' alt='...'>
<div class='card-body'>
<p class='card-title'><?= $resultproduct['name'] ?></p>
<p class='card-text'><?= $resultproduct['description'] ?></p>
<p class='card-text'><?= $resulttype['name'] ?></p>
<p class='card-text'><?= $resultproduct['price'] ?> $</p>
<a href='addpanier.php?id=<?= $resultproduct['id'] ?>' class='btn btn-primary'>Ajouter au panier</a>
</div>
</div>
</div>
<?php } ?>