Salve a tutti, sto imparando ad usare il linguaggio php però sono
rimasto bloccato. Qualcuno sa come potrei inserire questa funzione?
Cioè se il numero del campo PESO è maggiore del risultato di KG VOLUMETRICI la somma
di Largezza x Altezza x Profondità deve essere divisa per il campo
Peso solo se maggiore a Kg volumetrici o viceversa.
<form action="spese.php" method="post">
<table style="width: 500px" class="auto-style6">
<tr>
<td class="auto-style2" style="width: 206px">Larghezza</td>
<td><input name="larghezza" type="text" /></td>
</tr>
<tr>
<td style="width: 206px"></td>
<td></td>
</tr>
<tr>
<td class="auto-style2" style="width: 206px">Altezza</td>
<td><input name="altezza" type="text" /></td>
</tr>
<tr>
<td style="width: 206px"></td>
<td></td>
</tr>
<tr>
<td class="auto-style2" style="width: 206px">Profondità</td>
<td><input name="profondita" type="text" /></td>
</tr>
<tr>
<td class="auto-style2" style="width: 206px">Peso</td>
<td><input name="peso" type="text" /></td>
</tr>
<tr>
<td style="width: 206px"></td>
<td></td>
</tr>
<tr>
<td colspan="2" class="auto-style1">
<input name="Submit1" type="submit" value="Calcola" />
<input name="Reset1" type="reset" value="reset" /></td>
</tr>
<tr>
<td colspan="2" class="auto-style1"></td>
</tr>
<tr>
<td style="width: 206px">Kg volumetrici</td>
<td class="auto-style3">
<?php
$larghezza = $_POST['larghezza'];
$altezza = $_POST['altezza'];
$profondita = $_POST['profondita'];
$cinque ="5000";
$risultato=($larghezza*$altezza*$profondita/$cinque);
$campivuoti= "Tutti i campi devono essere compilati";
if ($altezza != '') {echo "$risultato";} else {echo "$campivuoti";}
?>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style="width: 206px">Prezzo</td>
<td class="auto-style4"><?php
if ($risultato == '') {echo "";}
elseif ($risultato<=30) {echo "6,50";}
elseif ($risultato<=50){echo "13,00";}
elseif ($risultato<=100){echo "23,00";}
elseif ($risultato<=200){echo "46,00";}
elseif ($risultato<=300){echo "69,00";}
elseif ($risultato<=400){echo "92,00";}
elseif ($risultato<=500){echo "115,00";}
elseif ($risultato<=600){echo "138,00";}
elseif ($risultato<=700){echo "161,00";}
elseif ($risultato<=800){echo "184,00";}
elseif ($risultato<=900){echo "207,00";}
elseif ($risultato<=1000){echo "230,00";}
?> </td>
</tr>
</table>
</form>
Grazie a tutti