este
Código PHP:
Ver original
<?php /*$db = mysql_connect("localhost", "root", "0000"); mysql_select_db("yo_demo",$db);*/ $id = $_POST["id"]; for ($i=0; $i < $id; $i++) { echo "<br/> #: ".$numfactura = $_POST["numfactura"][$i]; echo "<br/> Descripcion: ".$descripcion = $_POST["descripcion"][$i]; echo "<br/> Cantidad: ".$cantidad = $_POST["cantidad"][$i]; echo "<br/><br/>"; } /*for ($i=0; $i < $id; $i++) { $numfactura = $_POST["numfactura"][$i]; $descripcion = $_POST["descripcion"][$i]; $cantidad = $_POST["cantidad"][$i]; $sqlorden = "INSERT INTO demo(id, numfactura, descripcion, cantidad) VALUES ('','$numfactura','$descripcion','$cantidad')"; $result = mysql_query($sqlorden); }*/ } else { ?> <link href="astyles.css" rel="stylesheet" type="text/css" /> <form method="post" action="ddd.php" name="outputForm1"> <td><input type="hidden" name="id" id="id" value="1" /></td> <table id="tabla_1"> <thead> <tr> <th>Factura Nº </th> <th>Descripcion</th> <th>Cantidad</th> <th> </th> </tr> </thead> <tbody> <!-- Fila escondida, que va a llegar con un base 0 --> <tr id="clonable" style="display:none"> <td><input type="text" name="numfactura" /></td> <td><input type="text" name="descripcion" /></td> <td><input type="text" name="cantidad" /></td> <td><a href="#" onClick="borraFila(this.parentNode.parentNode)">Eliminar</a></td> </tr> <!-- Esta fila va a ser la clonada --> <tr id="tabla_1_fila_1"> <td><input type="text" name="numfactura" /></td> <td><input type="text" name="descripcion" /></td> <td><input type="text" name="cantidad" /></td> <td><a href="#" onClick="borraFila(this.parentNode.parentNode)">Eliminar</a></td> </tr> </tbody> <tfoot> <tr> <td colspan="n"> <a href="javascript:agregaFila( 'tabla_1' );">Agregar Fila</a> </td> </tr> </tfoot> </table> <input type="submit" name="submit" value="Aceptar"> </form> <? } ?> <script> function agregaFila( id ) { var tabla = document.getElementById( id ); var tbody = document.getElementById( tabla.id ).tBodies[0]; var row = tbody.rows[0].cloneNode( true ); var id = 1; while( document.getElementById( tabla.id+'_fila_'+id ) ) { id++; } row.id = tabla.id+'_fila_'+id; row.style.display = ''; tbody.appendChild( row ); document.getElementById("id").value = id; } function borraFila( fila, id ) { var id = fila.id; var filaM = document.outputForm1.id.value; if( fila.parentNode.rows.length <= 2 ) return; document.getElementById( id ).parentNode.removeChild( document.getElementById(id) ); document.getElementById("id").value = filaM - 1; } </script>
Al capturar los datos solo muestra un caracter y dependiendo de la posición del $i
captura esa poción y la almacena... No se que estoy realizando mal... necesito que se mustre todo...
Gracias por tener el tiempo de leer....