Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/02/2015, 08:48
mauriciop
 
Fecha de Ingreso: febrero-2015
Mensajes: 8
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Varias Consultas MySQL en PHP

Gracias por tu ayuda, lo solucione de la siguiente forma, pero la sucursal y los totales me salen al final de la tabla y yo los quiero al final de los datos por sucursal como se muesta en la [URL="https://drive.google.com/open?id=0B2zS-s4rpbhAbHdLdV9IcmZQWG8&authuser=0"]imagen[/URL]

Código PHP:
Ver original
  1. <page>
  2.       <table border='0.5'>
  3.         <tr>
  4.           <th style="width: 10%">N&deg; Ticket</th>
  5.           <th style="width: 10%">Marca</th>
  6.           <th style="width: 10%">Fecha ingreso</th>
  7.           <th style="width: 10%">Fecha final</th>
  8.           <th style="width: 5%">Precio</th>
  9.           <th style="width: 5%">(columna de verificación)</th>
  10.         </tr>
  11.  
  12.         <?php
  13.             $conexion = mysqli_connect($cfg['db_host'],$cfg['db_user'],$cfg['db_pass'],$cfg['db_name']);   
  14.               if(!$conexion) {
  15.                 echo "No se ha establecido la conexion>";
  16.               }
  17.           $sql = "SELECT productos.num_ticket, productos.marca, productos.fecha_ingreso, productos.fecha_fin, productos.precio, sucursales.descripcion
  18.                   FROM productos, sucursales
  19.                  WHERE sucursales.id_sucursal = productos.id_sucursal
  20.                  AND DATE( fecha_ingreso )
  21.                    BETWEEN  '$fecha1'
  22.                  AND  '$fecha2'
  23.                  ORDER BY sucursales.descripcion
  24.                  /*group by sucursales.descripcion*/
  25.                  LIMIT 0 , 30";
  26.           $result = mysqli_query($conexion, $sql);
  27.                     while($row = mysqli_fetch_array($result)){
  28.         ?>
  29.         <tr>
  30.            <td style="width:10%"><?php echo $row['num_ticket']; ?></td>
  31.            <td style="width:10%"><?php echo utf8_decode($row['marca']); ?></td>
  32.            <td style="width:10%"><?php echo utf8_decode($row['fecha_ingreso']); ?></td>
  33.            <td style="width:10%"><?php echo utf8_decode($row['fecha_fin']); ?></td>
  34.            <td style="width:5%"><?php echo utf8_decode($row['precio']); ?></td>
  35.            <td style="width:5%"><?php echo utf8_decode($row['descripcion']); ?></td>
  36.         </tr>          
  37.  
  38.         <?php
  39.         }
  40.         ?>
  41.         <?php
  42.           $conexion = mysqli_connect($cfg['db_host'],$cfg['db_user'],$cfg['db_pass'],$cfg['db_name']);  
  43.           if(!$conexion) {
  44.             echo "No se ha establecido la conexion>";
  45.           }
  46.  
  47.           $sql = "SELECT SUM(precio) AS total, sucursales.descripcion FROM productos, sucursales
  48.          WHERE sucursales.id_sucursal = productos.id_sucursal
  49.           AND DATE( fecha_ingreso )
  50.           BETWEEN  '$fecha1'
  51.           AND  '$fecha2'
  52.           GROUP BY sucursales.descripcion
  53.            LIMIT 0 , 30";
  54.           $result = mysqli_query($conexion, $sql);
  55.           while($row = mysqli_fetch_array($result)){
  56.         ?>
  57.           <tr>
  58.            <td style="width:5%"><?php echo utf8_decode($row['descripcion']); ?></td>
  59.             <td style="width:10%"></td>
  60.            <td style="width:10%"></td>
  61.            <td style="width:10%">Totales</td>
  62.            <td style="width:5%"><?php echo utf8_decode($row['total']); ?></td>
  63.            <td style="width:10%"></td>
  64.  
  65.         </tr>    
  66.         <?php
  67.         }
  68.         ?>
  69.     </table>
  70.     </page>

Última edición por mauriciop; 15/02/2015 a las 08:53 Razón: no se poner link de una imagen