I have a shopping cart with a table that list all the items you have in it with quantities, price and product name. Now I want users to be able to change the quantity of an item easily. How can I make this work? This solution I made up myself doesn't appear to work:
<tr>
<td><?=$item["product_id"]?></td>
<td>
<form method="post" id="<?=$item["product_id"]?>">
<input type="text" name="aantal" value="<?=$item["aantal"]?>">
<input type="submit" name="change_aantal_<?=$item["product_id"]?>" value="Update">
</form>
<?
if(isset($_POST["change_aantal_".$item["product_id"].""])) {
updateCart($item["id"], $_POST["aantal"]);
}
?>
</td>
<td><?=$item["aantal"] * $item["price"]?></td>
<td><a href="/removefromcart.php?id=<?=$item["id"]?>">Verwijderen</a></td>
</tr>
The function that actually does the updating works fine. It's just about how I make this form work.