Ver Mensaje Individual
  #7 (permalink)  
Antiguo 22/12/2013, 10:48
Avatar de boggiepopphantom
boggiepopphantom
 
Fecha de Ingreso: agosto-2012
Mensajes: 29
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Guardar valores de formulario creado dinámicamente

Bueno, modifiqué un poco el código, separé los formularios en archivos diferentes, y escribí la sentencia en donde se digitan los números, de la siguiente manera:

Código PHP:
echo "     <td align=\"center\"><input type=\"text\" name=\"\$notas[",$i,"]['fallas']\" size=\"4\" maxlength=\"4\" /></td>"
Ahora, en un archivo diferente, correspondiente al "action" del formulario, seguí la sugerencia de DNS:

Código PHP:
echo "Los valores ingresados son:";
echo 
"<pre>";
var_dump($_POST);
echo 
"</pre>"
Con lo que muestra lo siguiente:

Los valores ingresados son:

array(2) {
["$notas"]=>
array(19) {
[0]=>
array(2) {
["'fallas'"]=>
string(1) "1"
["'notas'"]=>
string(1) "1"
}
[1]=>
array(2) {
["'fallas'"]=>
string(1) "2"
["'notas'"]=>
string(1) "2"
}
[2]=>
array(2) {
["'fallas'"]=>
string(1) "3"
["'notas'"]=>
string(1) "3"
}
[3]=>
array(2) {
["'fallas'"]=>
string(1) "4"
["'notas'"]=>
string(1) "4"
}
[4]=>
array(2) {
["'fallas'"]=>
string(1) "5"
["'notas'"]=>
string(1) "5"
}
[5]=>
array(2) {
["'fallas'"]=>
string(1) "6"
["'notas'"]=>
string(1) "6"
}
[6]=>
array(2) {
["'fallas'"]=>
string(1) "7"
["'notas'"]=>
string(1) "7"
}
[7]=>
array(2) {
["'fallas'"]=>
string(1) "8"
["'notas'"]=>
string(1) "8"
}
[8]=>
array(2) {
["'fallas'"]=>
string(1) "9"
["'notas'"]=>
string(1) "9"
}
[9]=>
array(2) {
["'fallas'"]=>
string(1) "0"
["'notas'"]=>
string(1) "0"
}
[10]=>
array(2) {
["'fallas'"]=>
string(1) "1"
["'notas'"]=>
string(1) "1"
}
[11]=>
array(2) {
["'fallas'"]=>
string(1) "2"
["'notas'"]=>
string(1) "2"
}
[12]=>
array(2) {
["'fallas'"]=>
string(1) "3"
["'notas'"]=>
string(1) "3"
}
[13]=>
array(2) {
["'fallas'"]=>
string(1) "4"
["'notas'"]=>
string(1) "4"
}
[14]=>
array(2) {
["'fallas'"]=>
string(1) "5"
["'notas'"]=>
string(1) "5"
}
[15]=>
array(2) {
["'fallas'"]=>
string(1) "6"
["'notas'"]=>
string(1) "6"
}
[16]=>
array(2) {
["'fallas'"]=>
string(1) "7"
["'notas'"]=>
string(1) "7"
}
[17]=>
array(2) {
["'fallas'"]=>
string(1) "8"
["'notas'"]=>
string(1) "8"
}
[18]=>
array(2) {
["'fallas'"]=>
string(1) "9"
["'notas'"]=>
string(1) "9"
}
}
["suno"]=>
string(11) "Subir Notas"
}

Sin embargo, al hacer con un ciclo for:

Código PHP:
for($i=0;$i<$nf;$i++)
{
echo 
$notas[$i]['notas'];

No me muestra algo, queda la página vacía.

Cuando miro el código fuente del formulario, para ver cómo quedaron finalmente nombrados los input, me muestra lo siguiente

Código HTML:
<td align="center"><input type="text" name="$notas[0]['fallas']" size="4" maxlength="4" /></td> 
¿Alguna sugerencia? De antemano muchas gracias!