I'm trying to insert specific value to a MySQL table but whenever I do so, an error occurred and cant be inserted. As I traced it I noticed that the queries can only be inserted if all entities are given or all entities will be declared. How can I resolve this using PHP code?
if (isset($_POST['submit'])) {
$rec_qty=$_POST['rec_qty'];
$id=$_POST['item_id'];
for($i=0; $i < count($_POST['rec_qty']);$i++) {
$sql = mysqli_query($conn,"INSERT INTO itemlist (quantity) values('".$_POST['rec_qty'][$i]."') ") or die ("Error description: " . mysqli_error($conn));
$update = "$conn,UPDATE itemlist set quantity='$quantity' where item_id='$id'";
if($sql) {
header("Location: received_item.php?attempt=success");
} else {
header("Location: received_item.php?attempt=empty");
}
}
/**Error description: Field 'item_name' doesn't have a default value**/