我目前正在一次插入多行。我在“协议”表中有一个“id”列,设置为自动递增。这显然是为插入的每一行创建一个新的 id。
有没有办法一次插入所有具有相同 ID 的行?
if ($stmt = $mysqli->prepare("INSERT agreement (start, end, customer, manufacturer, item_number, item_description) VALUES (?, ?, ?, ?, ?, ?)")) {
$stmt->bind_param("ssssss", $start, $end, $customer, $manufacturer, $number, $description);
for ($i = 0; $i < count($_POST['item']); $i++) {
$number = $_POST['item'][$i];
$description = $_POST['description'][$i];
$theid2 = $theid[$i];
$stmt->execute();
}
$stmt->close();
}
// show an error if the query has an error
else {
echo "ERROR: Could not prepare SQL statement 1.";
}
// redirect the user
}
$mysqli->error;
$mysqli->close();