0
php and I have the product.php page, when clicking the product on the home page, I want you to redirect to product.php page showing the data of the particular product I clicked, I started the code more is not working, Thank you.
index php.
<?php
if (is_array($products)) {
foreach ($products as $id => $row) { ?>
<div class="col-sm-6 col-md-4 col-lg-3 mb-2">
<div class="card-deck">
<div class="card p-2 border-secondary mb-2">
<a href="product.php?id=<?= $row['product_id'] ?>">
<div class="hover-image">
<img class="card-img-top border-secondary" src="images/<?= $row['product_image'] ?>"/>
<a href="#"><span class="texto"></span></a>
</div>
</a>
<h3 class="text-center"><?= $row['product_name'] ?></h3>
<div class="text-center text-black rounded p-1" style="font-size: 20px;">Valor $<?= $row['product_price'] ?></div>
<button class="btn btn-success btn-block" type="button" value="Add to cart" onclick="cart.add(<?= $row['product_id'] ?>);">Adicionar ao carrinho</button>
</div>
</div>
</div>
<?php }
} else {
echo "No products found.";
}
?>
product php.
<?php
$products = $_GET["product_id"];
if (is_array($products)) {
foreach ($products as $id => $row) { }};
$row['product_name']
?>
where is the form with method get?
– Arthur Luiz
I did as follows, but I was not successful, even goes to page product.php with the id, but the page is all blank................ <form method="GET"action="product.php"> <a href="product.php?= <?= $Row['product_id'] ? >"> <div class="Hover-image"> <img class="card-img-top border-Secondary" src="images/<?= $Row['product_image'] ? >"/> <a href="#"><span class="text"></span></a> </div> </a> </form>
– user167454
already gave a print_r("<pre>"); print_r($_GET);Exit;
– Arthur Luiz