I'm trying to close this foreach function curly brace inside echo, while the function itself is outside of the echoed html code.
foreach ($_SESSION["shopping_cart"] as $product) {
echo
"<form class='info-confrim' action='includes/info.inc.php' method='post'>
<input type='hidden' name='product-name' value=".$product['name'].">
<input type='hidden' name='amount' value=".$product["quantity"].">
<input type='hidden' name='total-price' value=".$product['price'].">
".}."
<button class='submit-button' type='submit' name='info-
submit'>SUBMIT</button>
</form>";
I want the button to be outside for-each function so that it won't repeat itself but this method is not working at this time. I know I don't have enough knowledge and that's why I'm here.
This will probably work. This is another way of making for-each loop or any other statement ( if, while...) without curly brace
<form class='info-confrim' action='includes/info.inc.php' method='post'>
<?php foreach ($_SESSION["shopping_cart"] as $product): ?>
<input type='hidden' name='product-name' value=".$product['name'].">
<input type='hidden' name='amount' value=".$product["quantity"].>">
<input type='hidden' name='total-price' value=".$product['price'].">
<?php endforeach; ?>
<button class='submit-button' type='submit' name='info-submit'>SUBMIT</button>
</form>