Good afternoon, I would like to know where my error is, since what you said above does not work for me. I placed a print_r
and it gives me the following result ...
INSERT INTO trafos (centro) VALUES ('1')INSERT INTO trafos (centro) VALUES ('2')INSERT INTO trafos (centro) VALUES ('3')
that is, it theoretically captures it, but when it is saved in the bdd it only saves 1
<?php
$cantidadI=3;
include_once('conexion.php');
$centro =$_POST['centro'];
foreach ($_POST['centro'] as $key=>$values)
{
$guardar="INSERT INTO trafos (centro) VALUES ('".$values['centro']."')";
$result=mysql_query($guardar);
mysql_close();
}
?>
<div id="contenedor">
<form id="datos" method="post" action="#">
<div id="tabla" class="form-group">
<table>
<?php
for ($i=1; $i<=$cantidad; $i++) {
?>
<tr>
<td colspan="4" align="center">
<input id="centro" name="centro[<?php $i ?>][centro]" value="" type="text" />
</td>
</tr>
<?php
}
?>
</table>
<br>
</div>
<input id="guarda" type="submit" name="guarda" value="Guardar" />
<input id="cance" type="button" name="cance" value="Cancelar" />
</form>
</div>