tengo el siguinete codigo
$bd=conectarse();
//aqui busca el turno de trabajo
$nuevo=mysql_query("select * from asig_turnos_tra ",$bd);
while($reg9=mysql_fetch_array($nuevo))
{
$fecha = $reg9["fecha"];
list($dia,$mes,$anyo) = explode("-",$fecha);
$fecha_finis = $reg9["fecha_end"];
list($dia_1,$mes_1,$anyo_1) = explode("-",$fecha_finis);
if (($dia == $d1) && ($mes == $m1) && ($dia_1 <= $d2) && ($mes_1 == $m2) )
{
$dato_ope = $reg9["identificacion"];
$consecutivo_turno = $reg9["consecutivo"];
echo $consecutivo_turno;
//aqui deacuerdo al turno se selecciona el ingreso
$usu_bd=mysql_query("select * from ingreso_turno where consecutivo='$consecutivo_turno' ",$bd);
while($reg_usu_bd=mysql_fetch_array($usu_bd))
{
$total_tvd+=$reg_usu_bd["TVD"];
$total_tvt+=$reg_usu_bd["TVT"];
$total_tvp+=$reg_usu_bd["TVP"];
$total_tvp_2+=$reg_usu_bd["TVP_2"];
$total_total+=$reg_usu_bd["TOTAL_SU"];
echo'
<tr class=select style="font-size:12px" bgcolor="'.$color.'">
<td>
'.$reg_usu_bd["clientes"].'
</td>
<td>
'.number_format($reg_usu_bd["TVD"]).'
</td>
<td>
'.number_format($reg_usu_bd["TVT"]).'
</td>
<td>
'.number_format($reg_usu_bd["TVP"]).'
</td>
<td>
'.number_format($reg_usu_bd["TVP_2"]).'
</td>
<td>
'.number_format($reg_usu_bd["TOTAL_SU"]).'
</td>
</tr>
';
//}
//}
if ($color=="#E4E4E4")
{
$color="#DEE7EB";
}else{
$color="#E4E4E4";
}
}
}
}
mysql_free_result($usu_bd);
mysql_close($bd);
echo'
<tr align=center bgcolor="'.$color.'">
<td>
<b>TOTAL<b>
</td>
<td>
<b>'.number_format($total_tvd).'<b>
</td>
<td>
<b>'.number_format($total_tvt).'<b>
</td>
<td>
<b>'.number_format($total_tvp).'<b>
</td>
<td>
<b>'.number_format($total_tvp_2).'<b>
</td>
<td>
<b>'.number_format($total_total).'<b>
</td>
</tr>
<tr>
<td width=100% colspan=4>
<table width=100%>
<tr><td width=85%> </td>
<td width=15% align=center>
<a class="ico" title="Imprimir lista" href="" onClick="return printPage2()"><img src="img2/ico_imprimir.png" width="18" height="18" border=0><br>Imprimir</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<META http-equiv=Refresh content="300; URL=login.php">
';
?>
bueno el me hace el trabajo pero si el cliente en el dia me realizo varias compra el las detalla no me las suma. lo que quiero yo es me sume las compras en total que realizo cada cliente. y solo ponga una sola vez el nombre del cliente.
si alguien me puede ayudar por favor
gracias