3
I have a system for calculating product production. I insert the products and have to calculate the total amount of raw material that will be used.
Insert
Produto 1 (5g de ouro) - 10 quantidades
Produto 2 (3g de ouro) - 5 quantidades
My calculus appears like this:
Raw material
Ouro: 5 gramas * 10 = 50
Ouro: 3 gramas * 5 = 15
Pedra: 10 unidades
Diamante : 1
Diamante : 1
However I would like it to appear Grouped:
Ouro Total = 65
Pedra = 10
Diamante = 2
Thank you in advance.
My code
<?php
$query = "select material.*, producao.* from material LEFT JOIN producao
ON material.id_prod = producao.id_prod WHERE producao.id_producao ='$id'";
if ($result = mysqli_query($mysqli, $query)) {
while ($row = $result->fetch_assoc()) {
$material = utf8_encode($row['nome']);
$qtd = $row['qtd'];
$qtde = $row['qtde'];
$qtdTotal = $qtd * $qtde;
}
}
?>
You could update the question with the table columns
materal
andproducao
.– Bulfaitelo