Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/10/2010, 11:33
troyer4
 
Fecha de Ingreso: septiembre-2010
Mensajes: 22
Antigüedad: 13 años, 7 meses
Puntos: 0
Pregunta Problemas con Array

Hola amigos, tengo un problema y espero me puedan ayudar!!! Estoy generando un reporte en el cual me aparece una lista con varios conceptos digamos Truck y Total y lo q necesito hacer es agrupar los registros q tengan el mismo concepto digamos en este caso el concepto (Truck) y al final me de un subtotal que sume los Totales.. digamos
truck# total
28 100
subtotal 100
29 100
29 150
subtotal 250

y asi sucesivamente hasta q ya no aigan mas conceptos


EL codigo q uso para generar el reporte es este:

$registros2=mysql_query("select invotemp.*, ite.* from invoicestemp invotemp, items ite where invotemp.driver='$_REQUEST[idtruck]' and invotemp.item=ite.item and invotemp.ccost=ite.ccost and invotemp.date>='$_REQUEST[fechaini]' and invotemp.date<='$_REQUEST[fechafin]'",$link);
$num_registros=mysql_num_rows($registros2);
if ($num_registros==0)
{
$mensaje="No hay Items";
}
?>
<table width="100%" align="center">
<tr align="center">
<td width="8%"><div class="marco">Date</div></td>
<td width="12%"><div class="marco">Customer</div></td>
<td width="5%"><div class="marco">Truck #</div></td>
<td width="6%"><div class="marco">Ticket #</div></td>
<td width="12%"><div class="marco">From</div></td>
<td width="12%"><div class="marco">To</div></td>
<td width="6%"><div class="marco">L/T/H</div></td>
<td width="6%"><div class="marco">Rate</div></td>
<td width="6%"><div class="marco">Amount</div></td>
<td width="6%"><div class="marco">Total</div></td>

</tr>
<?php while ($fila=mysql_fetch_array($registros2))
{
?>
<tr align="center">
<td><?php echo $fila['date'];?></td>
<td><?php echo $fila['customer'];?></td>
<td><?php echo $fila['truck'];?></td>
<td><?php echo $fila['ticket'];?></td>
<td><?php echo $fila['fromitem'];?></td>
<td><?php echo $fila['toitem'];?></td>
<td><?php echo $fila['lth'];?></td>
<td><?php echo $fila['cbd'];?></td>
<td><?php $amount=$fila['lth']*$fila['cbd']; echo $amount;?> </td>
<td><?php $porcent=90; $porcent2=$porcent/100; $amount2=$amount*$porcent2; echo $amount2;?></td>
</tr>
<?php
}?>
</table>

Espero me aiga explicado y alguien me pueda ayudar..