Título: Crear Campos En una celda
Publicado por: alexkof158 en 3 Mayo 2012, 02:48 am
( ! ) Notice: Undefined index: filas in C:\wamp\www\Incertidumbre\tablas.php on line 17<body> <h1>Modelo de Incertidumbre</h1> <form action="tablas.php" method="POST"> Filas <input type="text" name="filas" size="3" maxlength="20" /><br /> Columnas<input type="text" name="colum" size="3" maxlength="20" /><br /> <input type="submit" value="Enviar" /> </form> <table> <?php $filas = $_REQUEST['filas']; $colum = $_REQUEST['colum']; for($i = 0; $i< $filas; $i++){ echo " <tr> "; for($j=0; $j < $colum; $j++){ echo " <td> $i x $j</td> "; } echo " </tr> "; } ?> </table> </body> :D Hola, apartir de haber creado la tabla siendo filas X columnas como podria hacer que me imprima un input para ingresar un dato??? :huh: Gracias de antemano
Título: Re: Notice: Undefined index:
Publicado por: ~ Yoya ~ en 3 Mayo 2012, 02:56 am
Bueno aqui el source con algunas modificaciones para evitar algunos errores... <body> <h1>Modelo de Incertidumbre</h1> <form action="index.php" method="POST"> Filas <input type="text" name="filas" size="3" maxlength="20" /><br /> Columnas<input type="text" name="colum" size="3" maxlength="20" /><br /> <input type="submit" value="Enviar" /> </form> <table style="border-style: solid;"> <?php //Verifico que se hayan enviado los datos via POST //Para evitar que todo el codigo corra sin datos que provocarian error... if(!empty($_POST['filas']) && !empty($_POST['colum'])) { $filas = $_REQUEST['filas']; $colum = $_REQUEST['colum']; for($i = 0; $i< $filas; $i++){ echo " <tr> "; for($j=0; $j < $colum; $j++){ echo " <td style=\"border-style: solid;\"> $i x $j</td> "; } echo " </tr> "; } } ?> </table> </body>
Saludos.
Título: Re: Crear Campos En una celda
Publicado por: alexkof158 en 3 Mayo 2012, 03:10 am
Gracias Yoya, ya me estaba leyendo que es mejor utilizar un If o Isset para evitar este tipo de errores, y Gracias
|