2
Personal created a form where I will put the quantity of products and send to the database, except that when I click to send is not saved only saved from one to one, someone could help me I’m trying to create this for days and I’m not getting.
here is the table created, What I need is to send them all at once. Can someone help me? this code below is working perfectly only that sends 1 in 1 need to send all at once.
<tr>
<td><input type="text" readonly class="form-control" name="codigo[]" id="inlineFormInputGroup" value="091822"></td>
<td><input type="text" readonly class="form-control" name="material[]" id="inlineFormInputGroup" value="TOMATE GRAPE 180"></td>
<td><input type="number" class="form-control" name="quantidade[]" id="inlineFormInputGroup" placeholder="Valor" ></td>
</tr>
<tr>
<td><input type="text" readonly class="form-control" name="codigo[]" id="inlineFormInputGroup" value="091822"></td>
<td><input type="text" readonly class="form-control" name="material[]" id="inlineFormInputGroup" value="TOMATE GRAPE 180"></td>
<td><input type="number" class="form-control" name="quantidade[]" id="inlineFormInputGroup" placeholder="Valor" ></td>
</tr>[![inserir a descrição da imagem aqui][1]][1]
<?php include_once"conexão.php";?>
<html>
<body>
<?php
$material = $_POST["material"];
$codigo = $_POST["codigo"];
$quantidade= $_POST["quantidade"];
$conn = mysqli_connect($servidor,$dbusuario,$dbsenha,$dbname);
mysqli_select_db($conn,'$dbname');
$sql = "INSERT INTO tblavitaperdas (material,codigo,quantidade) VALUES ('$material','$codigo','$quantidade')";
if (mysqli_query($conn, $sql)) {
echo "<script>alert('Salvei seus dados !'); window.location = 'perdaslavita.php';</script>";
}else{
echo "Deu errro: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
</body>
</html>
Good night, it’s been a while since I’ve touched php, but when you give the post the data, you need to go through it with a foreach and then enter it into the database, and in this case, you’re entering it once for all I can see.
– Pablo Harger