1
Good night, you guys! table is already almost ready only need take the value that is selected in the quantity field is less than 0 not send to the database so send the value that I put in the field $amount that is relevant more than 0 my help please...
html table fields.
<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>
CODE IN PHP
<body>
<?php
$material = $_POST["material"];
$codigo = $_POST["codigo"];
$quantidade= $_POST["quantidade"]; PRECISO QUE ENVIE ESSE VALOR SE ELE FOR PREENCHIDO MAIOR QUE 0.
$total_codigo = count($codigo);
$conn = mysqli_connect($servidor,$dbusuario,$dbsenha,$dbname);
mysqli_select_db($conn,'$dbname');
for($i = 0; $i < $total_codigo; $i++){
$sql = "INSERT INTO tblavitaperdas (material,codigo,quantidade) VALUES
('$material[$i]','$codigo[$i]','$quantidade[$i]')";
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>
cannot perform a validation before doing the Insert (
if ($quantidade > 0)
?– Ricardo Pontual
worst I’m not getting to make this validation I’ve tried several ways.
– Arthur Cesar