Zitat von hausl
Beitrag anzeigen
AHH! Jetzt habe ich es verstanden... vielen Dank!
$creator = $_SESSION['id'];
$timestamp = date('Y-m-d H:i:s');
$codetag = $_POST['cc_codetag'];
$amount = $_POST['amount'];
$i = 1;
$in_ = "INSERT INTO pub_codes (creator, created, codetag, code)
VALUES (?, ?, ?, ?)";
$ins_ = $db->prepare($in_);
$ins_ -> bind_param("ssss", $creator, $timestamp, $codetag, $wcode);
for ($i = 1; $i <= $amount; $i++){
$code = substr(str_shuffle('ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789'), 0, 10);
$wcode = $codetag . $code;
$ins_ -> execute();
}
INSERT INTO foo (bar, foobar, foo) VALUES (?, ?, ?), (?, ?, ?), (?, ?, ?), [...]
$creator = $_SESSION['id'];
$timestamp = date('Y-m-d H:i:s');
$codetag = $_POST['cc_codetag'];
$amount = $_POST['amount'];
$values = array();
$i = 1;
for ($i = 1; $i <= $amount; $i++){
$code = substr(str_shuffle('ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789'), 0, 10);
$wcode = $codetag . $code;
$values[] = "('$creator','$timestamp','$codetag','$wcode')";
}
$multi_insert = "INSERT INTO pub_codes (creator, created, codetag, code)
VALUES ".implode(",",$values);
$mysqli->query($multi_insert);
Kommentar