The thing is that I need the variable% co_of% which is where the total price of each product line is stored, something like $precioinicial
, $precioinicial1
, for later where I put the total without VAT , make the sum of these variables.
I have the following code snippet:
<table class="table table-bordered">
<thead>
<th>Cantidad</th>
<th>Producto</th>
<th>Precio Unitario</th>
<th>Total</th>
<th></th>
</thead>
<?php
/*
* Apartir de aqui hacemos el recorrido de los productos obtenidos y los reflejamos en una tabla.
*/
foreach($_SESSION["cart"] as $c):
$products = $con->query("select * from product where id=$c[product_id]");
$r = $products->fetch_object();
?>
<tr>
<th><?php echo $c["q"];?></th>
<td><?php echo $r->name;?></td>
<td><?php echo $r->price; ?> € </td>
<td><?php $precioinicial = $c["q"]*$r->price;
echo $precioinicial;?> € </td>
<td style="width:260px;">
<?php
$found = false;
foreach ($_SESSION["cart"] as $c) { if($c["product_id"]==$r->id){ $found=true; break; }}
?>
<a href="php/delfromcart.php?id=<?php echo $c["product_id"];?>" class="btn btn-danger">Eliminar</a>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Total sin IVA<br>
<?php echo $precioinicial;?> €
</td>
</tr>
</table>