I'm trying, unsuccessfully, to write some information in my database, I have a table where the user will insert rows according to his need, but when sending the information to the bank he is recording only the last information.
The table form is this:
<form action="insertKit.php" method="post" target="_blank">
<div class="table-responsive">
<table id="products-table" class="table table-hover table-bordered">
<tbody>
<tr>
<th width="15%">Nº</th>
<th width="16%">Qtde.</th>
<th width="15%">Código</th>
<th width="32%">Descrição</th>
<th width="22%" class="actions">Ações</th>
</tr>
<tr>
<td><input type="text" name="numero[]" ></td>
<td><input type="text" name="quantidade[]"></td>
<td><input type="text" name="codigo[]"></td>
<td><input type="text" name="descricao[]"></td>
<td class="actions">
<button class="btn btn-large btn-danger" onclick="RemoveTableRow(this)" type="button">Remover</button>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" style="text-align: left;">
<button class="btn btn-large btn-success" onclick="AddTableRow(this)" type="button">Adicionar Linha</button>
<button class="btn btn-large btn-primary" type="submit">Gravar</button>
</td>
</tr>
</tfoot>
</table>
</div>
</form>
The insert page is this:
for( $i=0; $i<count($_POST['numero']); $i++ ) {
// INSERINDO NO MYSQL
mysql_select_db($database_conexao, $conexao);
$query = "INSERT INTO kits
(numero,
quantidade,
codigo,
descricao
)
VALUES
(
'".$_POST['numero'][$i]."',
'".$_POST['quantidade'][$i]."',
'".$_POST['codigo'][$i]."',
'".$_POST['descricao'][$i]."'
)";
echo $query;
}
$queryExec = mysql_query($query, $conexao) or die('ERRO ao inserir registro no Banco');
if ( $queryExec) {
echo "GRAVADO COM SUCESSO";
} else {
echo "ERRO NA GRAVAÇÃO DO KIT";
}