Foros del Web » Programando para Internet » PHP »

formualrios y arrays

Estas en el tema de formualrios y arrays en el foro de PHP en Foros del Web. hola tengo 2 dias buscando la manera de hacer esto: formulario1 <form name="form1" method="post" action="agregar_prod.php"> <table width="375" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="dfdfdf" class="outline"> <tr> <td ...
  #1 (permalink)  
Antiguo 23/02/2008, 12:17
Avatar de LoUiMaNiAkO  
Fecha de Ingreso: enero-2006
Mensajes: 198
Antigüedad: 18 años, 3 meses
Puntos: 1
formualrios y arrays

hola tengo 2 dias buscando la manera de hacer esto:

formulario1

<form name="form1" method="post" action="agregar_prod.php">
<table width="375" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="dfdfdf" class="outline">
<tr>
<td width="177">Indique el numero de productos: </td>
<td width="70"><input name="ncampos" type="text" id="ncampos" size="8" /></td>
<td width="120" background="dfdfdf"><input type="submit" name="Submit" value="Enviar" /></td>
</tr>
</table>
</form>

<form name="form2" method="post" action="guardar.php">
<table width="789" border="0" align="center" cellpadding="0" cellspacing="1" class="outline">
<tr >
<td width="124" colspan="5">
<?
$cont = 1;
while($cont <= $ncampos) {
?>

<tr>
<td width="124">Clave:
<input name="new[<? echo $cont ?>]" type="text" size="5" value=""></td>
<td width="217">Nombre:
<input name="new[<? echo $cont ?>]" type="text" size="15" value=""></td>
<td width="284">Descripcion:
<input name="new[<? echo $cont ?>]" type="text" size="15" value=""></td>
<td width="157">Existencias:
<input name="new[<? echo $cont ?>]" type="text" size="5" value=""></td>
</tr><?
$cont++;
}
?><td width="124"></td>
</tr>
<tr>
<td class="outline" colspan="5"><div align="center"><input name="" type="hidden" value="$ncampos" />
<input name="agregar" type="submit" id="agregar" value="Aceptar"<? if(!$_POST){echo 'disabled';} else{ echo 'enabled'; }?> />
</div></td>
</tr>
</table>
</form>

y kiero imprimirlos pero no se como recuperar todos los campos ya que solo mi imprime uno cno este ejemplo

Código PHP:
<? 

$num_de_news 
0
if ( 
is_array $_POST['new'] ) ) 

foreach ( 
$_POST['new'] as $indice => $valor 
if ( 
$valor != "" 

$num_de_news++; // esto sería por si quieres contar el numero de news enviadas 
// también podrías aqui ya hacer tu insert usando $valor 
echo $valor;

?>
ayudeneme por favor
__________________
:molesto: "Soy como dios k nunca llora y como satanas k nunca resa":molesto:

Dejate seducir por mis colmillos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:28.