Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/08/2012, 13:14
ocp001a
Colaborador
 
Fecha de Ingreso: mayo-2008
Ubicación: $MX['VZ']['Xalapa']
Mensajes: 3.005
Antigüedad: 16 años
Puntos: 528
Respuesta: sumar la misma variable dentro de un while

Si hicieras algo como:
$meses[1]='Enero';
$meses[2]='Febrero'; etc
no necesitas tantos if y tanto código:

Código PHP:
Ver original
  1. $total=0;
  2. while ($fech=mysql_fetch_array($fechas)){
  3.    $timporte=$fech['tiva']+$fech['timporte'];
  4.    echo "
  5.   <tr>
  6.       <td>".$meses[$fech['MES']]."</td>
  7.       <td >$$timporte</td>
  8.   </tr>";
  9.    $total+=$timporte;
  10. }
  11. echo "<tr>
  12. <td></td>
  13. <td >TOTAL:</td>
  14. <td >$total</td>
  15. </tr>
  16. </table>";