Ver Mensaje Individual
  #11 (permalink)  
Antiguo 14/08/2009, 08:21
Twonex
 
Fecha de Ingreso: julio-2009
Ubicación: .mysql_error ( XD )
Mensajes: 554
Antigüedad: 14 años, 9 meses
Puntos: 13
Respuesta: Cómo Sumar una Fila Completa?

estimados... ya lo hize

lo que hize fue a cada mes asignarle una variable y luego de la manera más simple sume las variables, si el campo está en null simplemente lo omite, no da problemas!

igual muchas gracias por la ayuda!
saludo!


PD: dejo mi codigo!

Código PHP:
<?php
$consul 
"SELECT * FROM tablatotal WHERE año='$anio''";
    
$resul mysql_query ($consul) or die ("Error en consulta:".mysql_error());
    
    while (
$fila mysql_fetch_array($resul))
    {
        
$ene $fila ['enero'];        $feb $fila ['febrero'];
        
$mar $fila ['marzo'];        $abr $fila ['abril'];
        
$may $fila ['mayo'];        $jun $fila ['junio'];
        
$jul $fila ['julio'];        $ago $fila ['agosto'];
        
$sep $fila ['septiembre'];    $oct $fila ['octubre'];
        
$nov $fila ['noviembre'];        $dic $fila ['diciembre'];
        
        
$total $ene+$feb+$mar+$abr+$may+$jun+$jul+$ago+$sep+$oct+$nov+$dic;
?>

  <tr>
    <td class="letras3"><?php echo $fila["categorias"?></td>
    <td><?php echo $fila["enero"?></td>
    <td><?php echo $fila["febrero"?></td>
     ...
     ...
    <td><?php echo $total ?></td>
?>