Que tal, pues tengo esta consulta y dibujo una tabla:
Código PHP:
Ver original$sql="SELECT YEAR(fecha) AS ANIO, MONTH(fecha) AS MES, MONTHNAME(fecha) AS NOMBRE, SUM(iva) as tiva, SUM(importe) as timporte FROM solicitudes WHERE YEAR(fecha)='$anio' GROUP BY ANIO DESC , MES ASC";
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th>MES</th>";
echo "<th>IMPORTE</th>";
echo "</tr>";
echo "</thead>";
//inicia while
{
if($fech['MES'] == 1) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>ENERO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 2) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>FEBRERO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 3) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>MARZO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 4) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>ABRIL</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 5) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>MAYO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 6) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>JUNIO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 7) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>JULIO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 8) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>AGOSTO</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 9) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>SEPTIEMBRE</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 10) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>OCTUBRE</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 11) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>NOVIEMBRE</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
if($fech['MES'] == 12) {
$timporte=$fech['tiva']+$fech['timporte'];
echo "<tr>";
echo "<td>DICIEMBRE</td>";
echo "<td >$$timporte</td>";
echo "</tr>";
}
}
//fin while
echo "<tr>";
echo "<td></td>";
echo "<td >TOTAL:</td>";
//AQUI EL TOTAL DE $timporte
echo "<td >$</td>";
echo "</tr>";
echo "</table>";
COMO SE VE, EN CADA IF TENGO LA VARIABLE "$timporte" QUE ES EL RESULTADO DE UNA SUMA, PERO AHORA LO QUE QUIERO ES SUMAR TODAS LAS $timporte...Y SACAR EL TOTAL GENERAL...