Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/02/2011, 11:52
gordot
 
Fecha de Ingreso: febrero-2010
Ubicación: cba
Mensajes: 203
Antigüedad: 14 años, 2 meses
Puntos: 16
Respuesta: Consulta tabla con subtotales php

fijate con esto:



Código PHP:


<?
include("conectar.inc"); 
$SQL4 "select * from foro limit 0,10";
$RESULTADO4=mysql_query($SQL4);

?>                

<table border=1>
<tr>
<td>fecha</td>
<td>nombre</td>
<td>importe</td>
</tr>



<?
while($FILA4=mysql_fetch_array($RESULTADO4))

{
$total=$total+$FILA4[importe];

echo 
"<tr>";
echo 
"<td>";

echo 
$FILA4[fecha];
echo 
"</td>";


echo 
"<td>";

echo 
$FILA4[nombre];

echo 
"</td>";

echo 
"<td>";

echo 
$FILA4[importe];

echo 
"</td>";
echo 
"</tr>";

}
?>
<tr>
<td>subtotal: <?echo $total;?>   

</table>

$SQL5 = "select * from foro limit 0,20";
$RESULTADO5=mysql_query($SQL4);

?>                

<table border=1>
<tr>
<td>fecha</td>
<td>nombre</td>
<td>importe</td>
</tr>

anterior: <?echo $total;?> 

<?
while($FILA5=mysql_fetch_array($RESULTADO5))

{
$total2=$total2+$FILA5[importe];

echo 
"<tr>";
echo 
"<td>";

echo 
$FILA5[fecha];
echo 
"</td>";


echo 
"<td>";

echo 
$FILA5[nombre];

echo 
"</td>";

echo 
"<td>";

echo 
$FILA5[importe];

echo 
"</td>";
echo 
"</tr>";

}
?>

<?
$total3
=$total+$total2;
?>
<tr>
<td>total general : <?echo $total3;?>   

</table>