RE: [PHP-ES] Iterar dentro de dos foreach
| From: | Reynier Perez Mira | Date: | Sat, 25 Feb 2006 18:19:21 +0000 |
| Subject: | RE: [PHP-ES] Iterar dentro de dos foreach | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-57989@lists.php.net to get a copy of this message | ||
Bueno he probado pero no me funciona. Mira el código y errores abajo:
<?php
$max = 3;
echo "<form action=\"test.php?do=1\"
method=\"post\">"."<table width=\"20%\">";
for ($i = 0; $i < $max; $i ++) {
echo "<tr><td>";
echo "Nota: <input type=\"text\" name=\"notas[$i]\"
/></td>";
echo "<td>Desc: <input type=\"text\" name=\"desc[$i]\"
/></td>";
echo "<tr>";
}
echo "<tr><td colspan=\"2\"><input type=\"submit\"
value=\"Send\"></td></tr>"."</form>"."</table>";
if (isset ($_GET['do']) == 1) {
$i = 0;
foreach ($_POST as $arreglo) {
echo "INSERT INTO tabla(nota,desc)
VALUES(".$arreglo["notas"][$i].",".$arreglo["desc"][$i].")
<br>";
$i ++;
}
}
?>
Errores:
Notice: Undefined index: notas in D:\Server\WWWRoot\ejemplos\test.php on line 14
Notice: Undefined index: desc in D:\Server\WWWRoot\ejemplos\test.php on line 14
INSERT INTO tabla(nota,desc) VALUES(,)
Notice: Undefined index: notas in D:\Server\WWWRoot\ejemplos\test.php on line 14
Notice: Undefined index: desc in D:\Server\WWWRoot\ejemplos\test.php on line 14
INSERT INTO tabla(nota,desc) VALUES(,)
Que es lo que estoy haciendo mal ?
--
ReynierPM
4to. Ing. Informática
Linux User: #310201
El programador superhéroe aprende de compartir sus conocimientos. Es el referente de sus
compañeros. Todo el mundo va a preguntarle y él, secretamente, lo fomenta porque es así como
adquiere su legendaria sabiduría: escuchando ayudando a los demás...