triby muchas gracias ahi funciono de maravilla .. aparte el codigo queda mas limpia y facil de manipular -- deje codigo para otros que necesiten lo mismo
Código PHP:
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="titulo_busqueda">
<td width="138" height="35" align="center" bgcolor="#267EAC" class="">Localizador</td>
<td width="153" height="35" align="center" bgcolor="#267EAC" class="">fecha reserva </td>
<td width="150" height="35" align="center" bgcolor="#267EAC" class="">Monto Total</td>
<td width="138" height="35" align="center" bgcolor="#267EAC" class="">Comision</td>
<td width="75" height="35" align="center" bgcolor="#267EAC" class="">Total Hotel</td>
<td width="75" align="center" bgcolor="#267EAC" class="">Forma de Pago</td>
<td width="100" height="35" align="center" bgcolor="#267EAC" class="">DEBITO</td>
<td width="86" height="35" align="center" bgcolor="#267EAC" class="">CREDITO</td>
<td width="50" height="35" align="center" bgcolor="#267EAC" class="">Saldo</td>
</tr>
<?php $datos = array();
$j = 0;
do { $datos[$j]['localizador'] = $row_Recordset1['Localizador'];
$datos[$j]['fecha_reserva'] = $row_Recordset1['fecha_reserva'];
$datos[$j]['costo_total'] = $row_Recordset1['costo_total'];
//calculo comision
$comision =($row_Recordset1['costo_total'] * $row_Recordset1['comision']/100);
$datos[$j]['comision'] = $comision;
//calculo total Hotel
$totalahotel =($row_Recordset1['costo_total'] - $comision);
$datos[$j]['totalhotel'] = $totalahotel;
$datos[$j]['metodo_pago'] =$row_Recordset1['metodo_pago'];
//calculo debito
if ($row_Recordset1['metodo_pago']=="C" or $row_Recordset1['metodo_pago']=="S") { $datos[$j]['debito'] = 0;} if ($row_Recordset1['metodo_pago']=="G") {$datos[$j]['debito']= $comision; }
//calculo Credito
if ($row_Recordset1['metodo_pago']=="C") { $datos[$j]['credito'] = $totalahotel;} if ($row_Recordset1['metodo_pago']=="S") {if ($row_Recordset1['comision']==$row_Recordset1['sena']){$datos[$j]['credito'] = 0;} else {$datos[$j]['credito']=$row_Recordset1['monto_pago']- $comision ;}} if ($row_Recordset1['metodo_pago']=="G") {$datos[$j]['credito'] =0; }
// calculo saldo
$datos[$j]['saldo'] = $datos[$j-1]['saldo']+$datos[$j]['credito']-$datos[$j]['debito']; $j++;} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<?php $i =0; $debito = 0; for($j = count($datos) - 1; $j >= 0; $j--) {?>
<tr class="<?php if ($i % 2 == 0) {echo "fila_color_1";} else {echo "fila_color_2";}?>" >
<td width="138" height="40" align="center" valign="middle" class="texto_comun"><div align="center"><?php echo $datos[$j]['localizador']; ?></div></td>
<td width="153" height="40" align="center" valign="middle" class="texto_comun"><div align="center"><?php echo $datos[$j]['fecha_reserva']; ?></div></td>
<td width="150" height="40" align="center" valign="middle" class="nombre_aloja_CELES"><div align="center"><?php echo $datos[$j]['monto_total']; ?></div></td>
<td width="138" height="40" align="center" valign="middle" class=""><div align="center"><?php echo $datos[$j]['comision']; ?></div></td>
<td width="75" height="40" align="center" valign="middle" style="padding-left:30px"><div align="center"><?php echo $datos[$j]['totalhotel']; ?></div></td>
<td width="75" height="40" align="center" valign="middle" style="padding-left:30px"><div align="center"><?php echo $datos[$j]['metodo_pago']; ?></div></td>
<td width="100" height="40" align="center" valign="middle" class="texto_comun"><div align="center"><?php echo $datos[$j]['debito']; ?></div></td>
<td width="86" height="40" align="center" valign="middle" class="nombre_aloja_CELES"><div align="center"><?php echo $datos[$j]['credito']; ?></div></td>
<td width="50" align="center" valign="middle" class="nombre_aloja_CELES"><div align="center"><?php echo $datos[$j]['saldo']; ?></div> </a></td>
</tr>
<?php $i=$i+1; } ?>
<tr class="linea_inferior">
<td width="138" height="25" class="texto_comun"> </td>
<td width="153" height="25" class="texto_comun"> </td>
<td width="150" height="25" class="texto_comun"> </td>
<td width="138" height="25" class="texto_comun"> </td>
<td width="75" height="25" class="texto_comun"> </td>
<td width="75" height="25" class="texto_comun"> </td>
<td width="100" height="39" class="texto_comun"> </td>
<td height="39" colspan="2" class="nombre_aloja_CELES"><input name="num" type="hidden" id="num" value="<?php echo $num; ?>" />
<input name="reserva_id" type="hidden" id="reserva_id" value="<?php echo $row_Recordset2['reservas_id']; ?>" /></td>
</tr>
<tr>
<td colspan="9"> </td>
</tr>
</table>
espero que alguien le sirva
saludos ..