Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/10/2010, 13:15
ditin
 
Fecha de Ingreso: octubre-2010
Mensajes: 29
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: Problemas con Array

Código PHP:
Ver original
  1. $num_registros=mysql_num_rows($registros2);
  2. if ($num_registros==0)
  3.     {
  4.         $mensaje="No hay Items";
  5.     }else{
  6.  
  7.         echo "<table width='100%' align='center'>
  8.                 <tr align='center'>
  9.                     <td width='8%'><div class='marco'>Date</div></td>
  10.                     <td width='12%'><div class='marco'>Customer</div></td>
  11.                     <td width='5%'><div class='marco'>Truck #</div></td>
  12.                     <td width='6%'><div class='marco'>Ticket #</div></td>
  13.                     <td width='12%'><div class='marco'>From</div></td>
  14.                     <td width='12%'><div class='marco'>To</div></td>
  15.                     <td width='6%'><div class='marco'>L/T/H</div></td>
  16.                     <td width='6%'><div class='marco'>Rate</div></td>
  17.                     <td width='6%'><div class='marco'>Amount</div></td>
  18.                     <td width='6%'><div class='marco'>Total</div></td>
  19.                 </tr>";
  20.         while ($fila=mysql_fetch_array($registros2)) {
  21.                  if ($fila['id_camion']<>$antiguo_camion){
  22.                      echo $subtotal;
  23.                      $subtotal=0;
  24.                      $antiguo_camion = $fila['id_camion'];
  25.                 }else{
  26.                     $subtotal=$subtotal + $fila['cantidad'];
  27.                     echo "<tr align='center'>
  28.                             <td>".$fila['date']."></td>
  29.                             <td>".$fila['customer']."</td>
  30.                             <td>".$fila['truck']."</td>
  31.                             <td>".$fila['ticket']."</td>
  32.                             <td>".$fila['fromitem']."</td>
  33.                             <td>".$fila['toitem']."</td>
  34.                             <td>".$fila['lth']."</td>
  35.                             <td>".$fila['cbd']."</td>
  36.                          </tr>";
  37.                    
  38.                
  39.                 }
  40.             }

Mmmmm .... no entendi los ultimos dos campos que imprimias
$fila['id_camion'] = ese seria el campo de la id de camion ...
y $subtotal el subtotal obviamente ...
recomendacion un "ORDER BY ( POR LA ID DE CAMION )" en la consulta ....
y si puedes usar :

Select * from invoicestemp invotemp
inner join items ite ON invotemp.item = ite.item and invotemp.ccost = ite.ccost
WHERE invotemp.date>='$_REQUEST[fechaini]'
and invotemp.date<='$_REQUEST[fechafin]'
ORDER BY (ID CAMION)"
esa consulta creo estaria mejor y hace lo mismo .. si entendi bien ! xD