Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/12/2014, 12:06
Avatar de jors_11
jors_11
 
Fecha de Ingreso: marzo-2011
Ubicación: Granollers
Mensajes: 79
Antigüedad: 13 años, 1 mes
Puntos: 2
Pregunta Calculo en PHP

Hola a todos,

Estoy intentando practicando PHP e intento hacer un código para que me calcule el precio del transporte según el total de la factura, pero me doy cuenta que hay veces que me funciona y otras veces no me calcula nada, me podríais decir si he hecho algún error.
Gracias de antemano, Saludos


Código PHP:
Ver original
  1. <?php
  2.                 $total=($datos[$i]['Cantidad']*$datos[$i]['Precio'])+$total;
  3.             }
  4.                
  5.             if($total < 100) {
  6.             $sumar = 30;
  7.             }
  8.             if($total > 150) {
  9.             $sumar = 40;
  10.             }
  11.             if($total > 600) {
  12.             $sumar = 80;
  13.             }
  14.             if($total > 1000) {
  15.             $sumar = 160;
  16.             }
  17.             if($total > 3000) {
  18.             $sumar = 200;
  19.             }
  20.             if($total > 5000) {
  21.             $sumar = 300;
  22.             }
  23.             if($total > 6000) {
  24.             $sumar = 350;
  25.             }      
  26.            
  27.             $total2 = $sumar;
  28.            
  29.             $total3 = $total+$total2;
  30.             echo '<center><h2 id="total">Gastos de transporte: '.$total2.' €</h2></center>';
  31.             echo '<center><h2 id="total">Total: '.$total3.' €</h2></center>';
  32.             if($total!=0){
  33.                 }else{
  34.                 echo '<center><h2>No has añadido ningun producto</h2></center>';
  35.             }
  36.                    
  37.             ?>