I have a problem finding the largest value of the product box width for the freight of a website I'm making.
I put the product data with the size of the boxes in the database and I am now doing the calculations. I needed to add the weight and heights as the client requested and now I need to get the largest length and width of a set of products, but I can not do that ...
If anyone could help it would be great, follow the code below:
$total = 0;
$alturaTotal = 0;
$pesoTotal = 0;
$larguraTotal = 0;
foreach($_SESSION['carrinho'] as $id => $quantidade)
{
$sql = "SELECT * FROM produtos WHERE id = '$id'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
$produto = $row['nome'];
$preco = $row['preco'];
$id = $row['id'];
$altura = $row['altura'];
$largura = $row['largura'];
$comprimento = $row['comprimento'];
$peso = $row['peso'];
$cepOrigem = $row['cepOrigem'];
$sub = $preco * $quantidade;
$total = $total + $sub;
$alturaTotal = $alturaTotal + $altura;
$pesoTotal = $pesoTotal + $peso;
foreach($_SESSION['carrinho'] as $id => $largura)
{
$larguraTotal = $largura;
}