Debo hacer una consulta de una tabla para los mostrar en una tabla en el form los resultados de esa consulta, por cada fila que traiga debo agregar dos campos de text editables que son txtCalc y txtValorGas; si digito en txtCalc V debo hacer un calculo y mostrarlo en txtValorGas. Aqui les muestro mi codigo para que me puedan entender.
Código PHP:
<?php
echo "<table width='670' border='0' align='center'>";
$Sql = "select con_desp,des_condesp,cuenta,deb_cre_condesp from par_modpre
where t_prestamo=".$_REQUEST['txtLinea']." order by con_desp";
$Busq = ifx_query($Sql,$conexion);
$i = 0;
while($arrBusq = ifx_fetch_row($Busq))
{
echo "<tr bgcolor='#009100'>
<td width='329' bgcolor='#009100'><strong><font color='#000000' size='2'
face='Verdana, Arial, Helvetica, sans-serif'><input name='txtCodigo$i' readOnly type='text' class='texto'
id='txtCodSV2' value=".$arrBusq['con_desp']." size='3' maxlength='1'>-".$arrBusq['des_condesp']."</font></strong></td>
<td width='127'><font color='#FFFFFF'>Cuenta <input name='txtCuenta$i' readOnly type='text' class='texto'
id='txtCuenta' value=".$arrBusq['cuenta']." size='16' maxlength='12'></font></td>
<td width='25'><div align='center'><input name='txtCalc$i' type='text' class='texto' value='".$_REQUEST['txtCalc'.$i]."'
id='txtCalc$i' size='3' maxlength='1' onKeyPress='if(event.keyCode==13){submit();}'></div></td>";
echo "<td width='171'><font color='#FFFFFF'>Valor <input name='txtValorGas$i' type='text' value='$VL_ValorGas'".$i."'
class='texto' id='txtValorGas$i' size='25' maxlength='17' onKeyPress='if(event.keyCode>=48 && event.keyCode<=57){} else{event.keyCode=8;}'>
</font></td>
</tr>";
$i = $i + 1;
}
echo "</table>";
ifx_free_result($Busq);
for($j=0;$j<$i;$j=$j+1)
{
if($_REQUEST['txtCalc'.$j] == 'V')
{
$VL_ValorCred = $_REQUEST['txtValor'];
$VL_Plazos = $VL_Cuotas;
if($VL_ValorCred >= 300000)
{
$VL_SegVida = (($VL_ValorCred * 0.032) * $VL_Plazos)/100;
}
else
{
$VL_SegVida = 0;
}
$VL_ValorGas.$j = $VL_SegVida;
echo $VL_ValorGas.$j;
}
}
?>