![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
05/12/2007, 07:38
|
| | Fecha de Ingreso: noviembre-2007
Mensajes: 20
Antigüedad: 17 años, 2 meses Puntos: 0 | |
Re: ingresar 2 registros o mas a BD con campo autoincrement Hize tu programa y quiero saber como te conocectaste con el formulario, por yo lo hago, pero derminado por una variable, en vez de lo tuyo tengo:
for (i=0; i<$variable; $i++)
esto detrmino desde el cominenzo del formulario:
si el usuario me indica q' quiere ingresar tres registros, el van a aparecer tres lineas con cajas de texto y luego deberia guardar lo q' yo ingrese en las cajas de texto, es decir si son tres, debe guardar tres registos en una sola caja, o sea si indico q' ingreso 10 registros debe guardar 10 registros y lo q' no me lo traspasa desde un formulario a otro, eso quiero saber, gracias. Aquí están mis logicas: Programa 1: Código HTML: <form name="form1" method="post" action="/form2.php">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="45%"><label>Ingrese la cantiad de Personas q' desea ingresar</label></td>
<td width="3%"><div align="center">: </div></td>
<td width="32%"><input name="txtCantidad" type="text" id="txtCantidad"></td>
<td width="20%"><div align="center">
<input name="BtnAgregar" type="submit" id="BtnAgregar2" value="Agregar" style="width:120px;">
</div></td>
</tr>
</table>
</form> Programa 2: Código HTML: <?php $cantidad=$_POST["txtCantidad"]; ?>
<form name="form1" method="post" action="/ingreso_con_arreglos/form3.php">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4"><div align="center">Ingreso Multiple </div></td>
</tr>
<tr>
<td width="25%">Nombres</td>
<td width="25%">Apellidos</td>
<td width="25%">Telefono</td>
<td width="25%">Celular</td>
</tr>
<?php for ($i=0; $i < $cantidad; $i++)
{?>
<tr>
<td><input name="Campo1[]" type="text" id="Campo1[]" maxlength="40"></td>
<td><input name="Campo2[]" type="text" id="Campo2[]" maxlength="40"></td>
<td><input name="Campo3[]" type="text" id="Campo3[]" maxlength="12"></td>
<td><input name="Campo4[]" type="text" id="Campo4[]" maxlength="12"></td>
</tr>
<?php }?>
<tr>
<td colspan="4"><div align="center">
<input name="txtCantidad" type="hidden" value="<?php echo $cantidad; ?>">
<input name="BtnAgregar" type="submit" id="BtnAgregar" value="Agregar" style="width:120px;">
</div></td>
</tr>
</table>
</form> Programa 3: Código PHP: <?php
echo("<h1 align=center>Ingreso Multiple</h1>");
include('funcion_bd.php');
$cantidad = $_POST["txtCantidad"];
for ($i=0; $i<$cantidad; $i++) //Proceso de Registracion Multiple
{
$campo1[$i] = $_POST["campo1[]"];
$campo2[$i] = $_POST["campo2[]"];
$campo3[$i] = $_POST['campo3[]'];
$campo4[$i] = $_POST['campo4[]'];
echo($campo1[$i].' '.$campo2[$i].' '.$campo3[$i].' '.$campo4[$i].'<br>');
//Organizo los datos
$ingMSQL = "INSERT INTO t_dos (Nombres ,Apelido ,Telefono ,Celular)VALUES
('$campo1[$i]', '$campo2[$i]', '$campo3[$i]', '$campo4[$i]')";
//guardo los datos
echo($ingMSQL);
$resultadoMSQL = mysql_query($ingMSQL);
if ($resultadoMSQL) //Si guardo entonces me indicara que hizo esta operacion
echo "Ha ingresado exitosamente la Unidad: ";
else //En caso de no guardar los datos y en indicara un mensaje de error en el proceso
echo('no se puede ingresar datos<br>');
}
?> ¿mi pregunta es como sincronizar la caja de texto del formulario con la aplicacion hace todo el proceso par guardar los datos? ayudeme gracias.
Última edición por victormanuel2008; 05/12/2007 a las 08:05 |