Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2014, 09:19
marianomartelli
 
Fecha de Ingreso: agosto-2012
Ubicación: Barcelona
Mensajes: 243
Antigüedad: 11 años, 9 meses
Puntos: 1
Sumar totales en horizontal y vertical

Hola,

Tengo el siguiente problema:
La base de datos
es
categoria Enero Febrero Marzo ......Totales
Salarios 00 00 00
Irpf 00 00 00
Gas 00 00 00
---
---
Total 00 00 00


La cual tiene guardado los valore por meses y categorias el vaciado de estas estan bien lo que necesito es que me de los totales po fila y por columna.
Si alguien me puede sugerir como lo puedo hacer

dejo aquí el programa

Código PHP:
Ver original
  1. <?php
  2.  
  3. include("conexion.php");
  4. $consulta=("SELECT * FROM gastos  ORDER BY categoria");
  5.  
  6.  
  7. ?>
  8.  
  9. <?php
  10.  $datos=mysql_query($consulta,$conexion);
  11.  
  12.  
  13.  
  14.  
  15.  $tr_empresas="";
  16.  
  17.  
  18.         while($row = mysql_fetch_assoc($datos))
  19.        
  20.          
  21.        
  22.  {
  23.  
  24.    $tr_empresas.="
  25.  
  26.      
  27.    
  28.    <tr>
  29.         <td align='center'>".$row['categoria']."</td>
  30.         <td align='center'>".$row['01']."</td>
  31.         <td align='center'>".$row['02']."</td>
  32.         <td align='center'>".$row['03']."</td>
  33.         <td align='center'>".$row['04']."</td>
  34.         <td align='center'>".$row['05']."</td>
  35.         <td align='center'>".$row['06']."</td>
  36.         <td align='center'>".$row['07']."</td>
  37.         <td align='center'>".$row['08']."</td>
  38.         <td align='center'>".$row['09']."</td>
  39.         <td align='center'>".$row['10']."</td>
  40.         <td align='center'>".$row['11']."</td>
  41.         <td align='center'>".$row['12']."</td> 
  42.    </tr>
  43.     <tr>
  44.         <td><br></td>
  45.     </tr>
  46.  
  47.     ";
  48.    
  49.     }?>
  50.    
  51.  
  52.  
  53.  
  54. <style>
  55.  body{font-family:Arial, Helvetica, sans-serif; font-weight:bold;}
  56.  table.tabla_empresa{border:none;border-collapse:collapse}
  57.  table.tabla_empresa{background-color:#BFBFBF;width:120%;}
  58.  table.tabla_empresa th{background-color:#4D4D4D;color:#FFFFFF;border:1px solid #E6E6FA}
  59.  table.tabla_empresa td{background-color:#FFFFFF;color:#08285A;font-weight:bold;}
  60.  </style>
  61.  
  62.  
  63.  
  64. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  65.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  66. <!--
  67.  
  68.     Design by Free CSS Templates
  69.     http://www.freecsstemplates.org
  70.     Released for free under a Creative Commons Attribution License
  71.  
  72.     Name       : Eponymous
  73.     Version    : 1.0
  74.     Released   : 20130222
  75.  
  76. -->
  77. <html xmlns="http://www.w3.org/1999/xhtml">
  78.     <head>
  79.         <meta name="keywords" content="" />
  80.         <meta name="description" content="" />
  81.         <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
  82.      
  83.         <title></title>
  84.         <link href="css/paginacion.css" type="text/css" rel="stylesheet">
  85.         <link href="css/style.css" rel="stylesheet" type="text/css" />
  86.         <link href="css/menu.css" rel="stylesheet" type="text/css" />
  87.     </head>
  88.     <body>
  89.         <div id="bg">
  90.             <div id="outer">
  91.                 <div id="header">
  92.                     <div id="logo">
  93.                         <h1>
  94.                             <a href="index.html"></a>
  95.                         </h1>
  96.                     </div><br><br>
  97.                    
  98.                    
  99.                 <h2  style="font-weight:bold; color:#FF8E18; text-align:center; font-size: 36px;">Gastos por año</h2>
  100.                 <p   style="font-weight:bold; color:#FF8E18; text-align:center; font-size: 12px;"> Para imprimir exportar la base de datos a excel</p>
  101.  
  102.                
  103.  
  104.          <br />
  105.          <div id= "centrar_tabla">
  106.          <table class='tabla_empresa'>
  107.          <tr>
  108.                  <th>Descripcion</th>
  109.                  <th>Enero</th>
  110.                  <th>Febrero</th>
  111.                  <th>Marzo</th>
  112.                  <th>Abril</th>
  113.                  <th>Mayo</th>
  114.                  <th>Junio</th>
  115.                  <th>Julio</th>
  116.                  <th>Agosto</th>
  117.                  <th>Septiembre</th>
  118.                  <th>Octubre</th>
  119.                  <th>Noviembre</th>
  120.                  <th>Diciembre</th>
  121.                  <th>Totales</th>
  122.                  
  123.          </tr>
  124.                 <?php echo $tr_empresas;?>
  125.          </table>
  126.                    
  127.                
  128.     </body>
  129. </html>


Gracias y saludos