<?php
$works = [
'type' => [1, 5],
'description' => [2, 6],
'hours' => [3, 7],
'amount' => [4, 8]
];
if (!empty($works['type'])) {
$sql = "INSERT INTO works (type, description, hours, amount)
VALUES (?,?,?,?)";
$stmt = $mysqli->prepare($sql);
for ($i = 0, $count = count($works['type']); $i < $count; ++$i) {
$stmt->bind_param(
"iiii",
$works['type'][$i],
$works['description'][$i],
$works['hours'][$i],
$works['amount'][$i]
);
$stmt->execute();
}
}
var_export($mysqli->query("SELECT * FROM works")->fetch_all(MYSQLI_ASSOC));