Hi all expert here,
please refer to attached image, I had a table which mainly stored add-to-cart items, user might able to check what's item was in their cart and do remove or update item's quantity as like common cart we use for online shopping. I was able to loop and called up related records from add-to-cart table and show on front-end, the problem is the submit button (update button), its always post back / pointed to last record, which is J001 with quantity '7' although I try to update K001 or P001 item's quantity, is that any method to solve this kind of problem?
The form I've use is POST method, below echoes is a test whether the submission passing the correct values (unfortunately its keeps return me last row).
if(isset($_POST["btnUpdate"])){
$itm_qty = $_POST["txtQty"];
$hidden_id = $_POST["hidden_id"];
echo $itm_qty."<br>".$hidden_id."<br>";
}
<input type='text' name='txtQty' value='".$rows['totalInCart']."'>
<input type='hidden' name='hidden_id' value='".$rows['itm_id']."'>
<button type='submit' name='btnUpdate'>Update</button>
Thanks to everyone to give me solution or advise.