Foros del Web » Programando para Internet » PHP »

convertir sentencia sum de mysql a php

Estas en el tema de convertir sentencia sum de mysql a php en el foro de PHP en Foros del Web. hola, como puede definir la siguiente sentencia en una tabla de php según lineas abajo. @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código MySQL: Ver original SELECT Fecha , TipoDeProducto ...
  #1 (permalink)  
Antiguo 19/01/2016, 11:45
 
Fecha de Ingreso: enero-2016
Mensajes: 19
Antigüedad: 8 años, 2 meses
Puntos: 0
convertir sentencia sum de mysql a php

hola,

como puede definir la siguiente sentencia en una tabla de php según lineas abajo.

Código MySQL:
Ver original
  1. SELECT Fecha,TipoDeProducto,Region,Pais,Cliente,SUM(C_Est_Neto),SUM(Cant_Cajas),Precio_FCA_Promedio,SUM(Importe),SUM(Flete),SUM(Descuento), SUM(Valor_Neto_Total) FROM resumenbeta WHERE tipodeproducto LIKE 'uvas be'GROUP BY Pais

Código PHP:
Ver original
  1. $registro = mysql_query("SELECT Fecha,TipoDeProducto,Region,Pais,Cliente,SUM(C_Est_Neto),SUM(Cant_Cajas),Precio_FCA_Promedio,SUM(Importe),SUM(Flete),SUM(Descuento), SUM(Valor_Neto_Total) FROM resumenbeta WHERE tipodeproducto LIKE '%$dato%' GROUP BY Pais", $conexion);


Código PHP:
Ver original
  1. <?php
  2. include('conexion.php');
  3.  
  4. //$dato = $_POST['dato'];
  5.  
  6. $dato="";
  7. if (isset($_POST['dato'])) {$dato = $_POST['dato'];}
  8.  
  9. //EJECUTAMOS LA CONSULTA DE BUSQUEDA
  10.  
  11. $registro = mysql_query("SELECT Fecha,TipoDeProducto,Region,Pais,Cliente,SUM(C_Est_Neto),SUM(Cant_Cajas),Precio_FCA_Promedio,SUM(Importe),SUM(Flete),SUM(Descuento), SUM(Valor_Neto_Total) FROM resumenbeta WHERE tipodeproducto LIKE '%$dato%' GROUP BY Pais", $conexion);
  12.  
  13. //CREAMOS NUESTRA VISTA Y LA DEVOLVEMOS AL AJAX
  14.  
  15. echo '<table class="table table-striped table-condensed table-hover">
  16.            <tr>
  17.                <th width="80">Fecha</th>
  18.                <th width="150">Tipo De Producto</th>
  19.                <th width="150">Region</th>
  20.                <th width="150">Pais</th>
  21.                <th width="350">Cliente</th>
  22.                <th width="150">C. Est. Neto</th>
  23.                <th width="150">Cant. Cajas</th>
  24.                <th width="150">Precio FCA</th>
  25.                <th width="150">Importe</th>
  26.                <th width="150">Flete</th>
  27.                <th width="150">Descuento</th>
  28.                <th width="150">Valor Neto Total</th>
  29.            </tr>';
  30. if(mysql_num_rows($registro)>0){
  31.     while($registro2 = mysql_fetch_array($registro)){
  32.         echo '<tr>
  33.                <td>'.fechaNormal($registro2['Fecha']).'</td>
  34.                <td>'.$registro2['TipoDeProducto'].'</td>
  35.                <td>'.$registro2['Region'].'</td>
  36.                <td>'.$registro2['Pais'].'</td>
  37.                <td>'.$registro2['Cliente'].'</td>
  38.                <td>'.$registro2['C_Est_Neto'].'</td>
  39.                <td>'.$registro2['Cant_Cajas'].'</td>
  40.                <td> $.'.$registro2['Precio_FCA_Promedio'].'</td>
  41.                <td> $.'.$registro2['Importe'].'</td>
  42.                <td> $.'.$registro2['Flete'].'</td>
  43.                <td> $.'.$registro2['Descuento'].'</td>
  44.                <td> $.'.$registro2['Valor_Neto_Total'].'</td>
  45.                <td><a href="javascript:editarProducto('.$registro2['Fecha'].');" class="glyphicon glyphicon-edit"></a> <a href="javascript:eliminarProducto('.$registro2['Fecha'].');" class="glyphicon glyphicon-remove-circle"></a></td>
  46.                
  47.                </tr>';
  48.     }
  49. }else{
  50.     echo '<tr>
  51.                <td colspan="6">No se encontraron resultados</td>
  52.            </tr>';
  53. }
  54. echo '</table>';
  55. ?>

Última edición por jjgonzalesf; 19/01/2016 a las 11:49 Razón: actualización de datos
  #2 (permalink)  
Antiguo 19/01/2016, 12:15
 
Fecha de Ingreso: agosto-2010
Ubicación: santiago, CHILE
Mensajes: 564
Antigüedad: 13 años, 7 meses
Puntos: 9
Respuesta: convertir sentencia sum de mysql a php

no te funciona la query?

prueba esto en los campos que estas sumando.

Código PHP:
Ver original
  1. $registro = mysql_query("SELECT Fecha,TipoDeProducto,Region,Pais,Cliente,SUM(C_Est_Neto) as C_Est_Neto, etc...

Etiquetas: fecha, mysql, registro, select, sentencia, sql, sum, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:41.