I am creating a shopping cart but I have a problem, if I have several products chosen, then, I want that when I click on the button to delete some product because the price of the eliminated product is subtracted from the total amount, I have been told that in order not to recharge, I should do it in query.
<div class="producto">
<center>
<img src="./productos/<?php echo $datos[$i]['Imagen']; ?>"><br>
<span><?php echo $datos[$i]['Nombre']; ?></span><br>
<span>Precio: <?php echo $datos[$i]['Precio']; ?></span><br>
<span>Cantidad:
<input type="text" value="<?php echo $datos[$i]['Cantidad']; ?>"
data-precio="<?php echo $datos[$i]['Precio']; ?>"
data-id="<?php echo $datos[$i]['Id']; ?>" class="cantidad">
</span><br>
<span class="subtotal">Subtotal:<?php echo $datos[$i]['Cantidad'] * $datos[$i]['Precio']; ?></span><br>
<a href="#" class="eliminar" data-id="<?php echo $datos[$i]['Id'] ?>">Eliminar</a>
</center>
</div>
<?php
$total = ($datos[$i]['Cantidad'] * $datos[$i]['Precio']) + $total;
}