bien el tema esta en k tengo el siguiente php el cual realiza un LISTADO DE CONSUMO DE UN PRODUCTO X:
Código php:
Ver original
<!-- <?php include('conec.php'); conectarse(); function array_flatten($array, &$newArray ,$prefix='',$delimiter='|') { foreach ($array as $key => $child) { { $newPrefix = $prefix.$key.$delimiter; $newArray =& array_flatten($child, $newArray ,$newPrefix, $delimiter); }else { $newArray[$prefix.$key] = $child; } } return $newArray; } $sql="SELECT idFactura,compra_serializada2,estatus,factura.idUsername,usuario.username,establecimiento FROM factura LEFT JOIN usuario ON factura.idUsername=usuario.username WHERE estatus='atendido'"; ?> <body> <table border=1> <tr>Consumo del Producto X <?php { $array=$carro2; array_flatten($array,$newArray); //print_r( $newArray )."<br />"; ?> <form name="" method="post" action="archivo.php"> <tr> <td><?php echo $row['idFactura'] ?></td> <td><?php echo $row['establecimiento'] ?></td> <td> <?php $cantidad_autorizada=$newArray['06d84b98e0d1df|cantidad_autorizada']; if($cantidad_autorizada=="") { echo $cantidad=0; }else { echo $cantidad=$cantidad_autorizada; } ?> </td> </tr> <?php } ?> </table> </form> </body>-->
y este es el resultado:
idFactura establecimiento cantidad
--------------------------------------------------
00111 Establecimiento 11 0
00113 Establecimiento 11 0
00114 Establecimiento 33 80
00117 Establecimiento 33 60
00120 Establecimiento 33 40
00119 Establecimiento 99 9000
****Entonces el punto está en k el LISTADO cambie a: "CONSUMO DEL PRODUCTO X POR C/ESTABLECIMIENTO", entiendo k DEBO USAR para este caso el GROUP BY...
establecimiento cantidad
---------------------------------------------
Establecimiento 11 0 (0+0)
Establecimiento 33 180 (80+60+40)
Establecimiento 99 9000 (9000)
pero como podría implementarlo para este caso, se podrá???
Gracias de antemano