I have a small, primitive shopping cart I am building for learning purposes (security is not an issue, this is just to help learn theory).
Right now I am trying to give functionality to updating the cart. At the moment, the following code works mostly:
$sql = $connection->prepare("UPDATE cart SET quantity=? WHERE productID=?");
foreach (array_combine($_POST['productID'], $_POST['quantity']) as $key => $value) {
$sql->execute(array(
$value,
$key
));
}
What I would like to do now, is sort by a third column. I have created a third item descriptor, zodiac sign, and I would like to sort through all three.
So based on the product chosen, it sends the Zodiac sign, quantity of the item purchased, and the productID of the item. My problem with this particular code is that I have some of the same products but with different zodiac signs. So if I change the quantity of those two items that have the same zodiac sign, it changes the quantity of both of them.
So I have the two arrays for productID, and quantity. Now I need one for zodiac. How can I then combine those 3 arrays, and send that data to the sql table?