Hello everyone.
In the task, you need to display the product in a cycle and inside the information about each product there is a counter, which on click increases the product by 1. When I click on one product, the value of all products changes. I do not understand how to make a condition to act only for one product. Below is how I do (sorry if I format it incorrectly):
<?php $dbconnect; $var_order_id = (int)$_GET['ordid']; $c_result = pg_query("SELECT i.image, i.name, c.prod_price, c.prod_count, c.id_cart FROM cart as c join items as i on i.id = c.prod_id WHERE c.order_id = '$var_order_id'"); $div_numc = pg_num_rows($c_result); for($i=0; $i < $div_numc; $i++){ $cart_catalog = pg_fetch_array($c_result); $id_cart = $cart_catalog['id_cart']; //При клике на кнопку делаю вот этот апдейт. if(isset($_POST['subplus'])){ $update_query = pg_query("UPDATE cart SET prod_count = prod_count+1, sum_price = prod_price*(prod_count+1) WHERE id_cart = '$id_cart' returning prod_count"); $v_prod_count = pg_fetch_array($update_query); $var_prod_count = $v_prod_count['prod_count']; } ?> Here is the html with what I print.
<?php } ?>