1
Hello, I have a question on how to make an entry in a database.
while($row = $result->fetch_assoc()) {
echo "<div class=\"card\" style=\"width: 18rem;\">";
//echo "<img class=\"card-img-top\" src=\"...\" alt=\"Card image cap\">";
echo '<img class=\"card-img-top\" src="data:image/jpeg;base64,' . base64_encode($row['imagem']) .'"/>';
echo "<div class=\"card-body\">";
echo "<h5 class=\"card-title\">Card title</h5>";
echo "<p class=\"card-text\">Some quick example text to build on the card title and make up the bulk of the card's content.</p>";
echo "</div>";
echo "<ul class=\"list-group list-group-flush\">";
echo "<li name=\"prod\"class=\"list-group-item\">".$row['id_Produto']."</li>";
echo "<li class=\"list-group-item\">".$row['nome']."</li>";
echo "<li class=\"list-group-item\">Vestibulum at eros</li>";
echo "</ul>";
echo "<div class=\"card-body\">";
echo "<a href = \"adicionarCarrinho.php\" method = \"post\"class=\"card-link\">Adicionar ao carrinho</a>";
echo "</div>";
echo "</div>";
What I’m trying to do is when the user clicks the button echo "<a href = \"adicionarCarrinho.php\" method = \"post\"class=\"card-link\">Adicionar ao carrinho</a>";
a php file get the .$row['id_Produto'].
and add in an ordered table where it contains id_order and a foreign key producto_id. In case they would have multiple products and one user could add several to the order.
This can only be done in php(college work) Thank you
I believe the best way is using ajax.
– Vinicius De Jesus
I can’t, PHP only required
– spider tek
then create a form with only the subtmit button on each product card. and every time you submit add to cart and redirect to that same page.
– Vinicius De Jesus
and an Hidden type with the product id.
– Vinicius De Jesus