Ver Mensaje Individual
  #8 (permalink)  
Antiguo 08/09/2011, 09:40
ariel_buc
 
Fecha de Ingreso: enero-2010
Mensajes: 30
Antigüedad: 14 años, 3 meses
Puntos: 0
Respuesta: Sumar una fila en php

Aca les dejo el código, desde ya muchas gracias


Código PHP:
<?php
    $c 
mysql_connect('localhost''root''');
    
mysql_select_db('economia_domestica');
     
     
$sql 'select Periodo, sum(luz+gas) as total from gastosmensuales group by Periodo';
    
$res mysql_query($sql) or die(mysql_error());
     
    while (
$reg mysql_fetch_array($res)) {
        echo 
$reg['total'] . '<br />';
    }
   
     
$sqlrs1 "SELECT * FROM gastosmensuales ORDER BY Periodo ASC";
    
$rs1 mysql_query($sqlrs1) or die(mysql_error());
    
$row_rs1 mysql_fetch_assoc($rs1);
    
$totalRows_rs1mysql_num_rows($rs1);
    
?>
    
 <table border="1">
   <tr>
       <td>id</td>
       <td>Periodo</td>
       <td>gas</td>
       <td>luz</td>
       <td>total</td>
   </tr>
    <?php do { ?>
   <tr>
        <td><?php echo $row_rs1['id']; ?></td>
        <td><?php echo $row_rs1['Periodo']; ?></td>
        <td><?php echo $row_rs1['gas']; ?></td>
        <td><?php echo $row_rs1['luz']; ?></td>
        <td>[B][COLOR="Red"]// Aca quiero que se vean los resultado//[/COLOR][/B] </td>
    </tr>    
    <?php } while ($row_rs1 mysql_fetch_assoc($rs1));?>
    </tr>
</table>
<?php
mysql_free_result
($rs1);
?>