Ver Mensaje Individual
  #11 (permalink)  
Antiguo 16/11/2010, 05:36
gandres
 
Fecha de Ingreso: noviembre-2010
Mensajes: 13
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Ingreso de datos Desde campos de texto dinamicos a bd

Me parece que el tema viene por los input y los checkbox. Al ser varios deberías crearte un array de ellos:

while (is_array($datos)){
?> <table width="368" border="0">
<tr>
<td width="300"><input type="checkbox" name="id[]" value="<?php echo ($datos['id_pro']) ?>">&nbsp;&nbsp;<?php echo ($datos['nom_pro']) ?></td>
<td> <input name="cantidad[]" type="text" size="8"></td>
</tr>
<?php
$datos=mysql_fetch_array($sql);
}

Ahora tienes el array con los input, para gravar tienes que fijarte si existe el id[] (o sea que haya sido marcado) y grabar:

<?php
include("conexion.php");
$link=Conectarse();
$dia=$_POST['dia'];
$mes=$_POST['mes'];
$ano=$_POST['ano'];
$fecha="$ano-$mes-$dia";
$cliente=$_POST['cliente'];
$monto=$_POST['monto'];
$id=$_POST['id'];
$enviar=$_POST['enviar'];
$cantidad=$_POST['cantidad'];

if (!empty ($cliente) AND ($monto) and ($fecha)) {
if ($enviar=="Grabar"){
for($i=0;$i<count($_POST['cantidad'];++$i) {
if(isset($_POST['id][$i]{
mysql_query("INSERT INTO detalle (id_pro_det,can_pro_det) VALUES ('".$id[$i]."','".$cantidad[$i]."')",$link) or die(mysql_error());
mysql_query("INSERT INTO factura (fec_fac,ced_cli,val_tot) VALUES ('".$fecha."','".$cliente."','".$monto."')",$lin k) or die(mysql_error());
}
header ("Location:ventas.php");
}
}
?>