Good, I have this query that I show in a table:
$sql2 = "SELECT * FROM cart_product
JOIN cart_product_to ON cart_product.cart_id
JOIN product ON cart_product.product_id = product.id
JOIN cart ON cart_product.cart_id = cart.id
WHERE cart_product_to.cart_idt = cart_product.cart_id
AND cart.delegado = '". $_POST["deleg"]."'
AND cart.created_at BETWEEN '".$newDatemin."' AND '".$newDatemax."'
AND cart.client_email LIKE '%". $_POST["cliente"]."%'";
$result2 = $con->query($sql2);
The table:
echo "<table class='datagrid' style='color:#000'>
<tr>
<th class='datagrid'>Numero de pedido</th>
<th class='datagrid'>Fecha</th>
<th class='datagrid'>Cliente</th>
<th class='datagrid'>Productos</th>
<th class='datagrid'>Cantidad</th>
<th class='datagrid'>Precio</th>
<th class='datagrid'>Delegado</th>
</tr>";
while(@$row = $result2->fetch_assoc()) {
echo "<tr>
<td class='datagrid'>".$row["id"]."</td>
<td class='datagrid'>".$row["created_at"]."</td>
<td class='datagrid'>".$row["client_email"]."</td>
<td class='datagrid'>".$row["name"]."</td>
<td class='datagrid'>".$row["q"]."</td>
<td class='datagrid'>".$row["q"]*$row["price"]."</td>
<td class='datagrid'>".$row["delegado"]."</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class='datagrid'>Total Pedido: ".$row["totalpedido"]."</td>
</tr>";
}
echo "</table>";
}
The story is that he does it well, but what he shows me are the results of the order and below each line of order the total of the order.
I have that total order stored in a separate table: $row["totalpedido"]
, which contains the id of the order and the total only, the thing is that I want that total to appear below all the lines of the order.
For example, they ask for an item a with price x, an article b with a price, and two items c with a price z, these three items have the same shopping cart id, and this id has the price of the total stored car associated with it in bbdd, but of course I need that total to be shown after the three items ordered, I do not know if I have explained myself well, I hope so.
Thank you.