更新代码:
if (isset($_POST['submit'])) {
/* Create a prepared statement */
$query = "INSERT INTO log_dates(week_date, crew_chief, monday_crew) values(?,?,?)";
$stmt = mysqli_prepare($connection, $query);
$returnedData = $_POST['data'];
foreach($returnedData as $data) {
$week_date = $data['week_date'];
$crew_chief = $data['crew_chief'];
$monday_crew = $data['monday_crew'];
$stmt->execute();
}
mysqli_stmt_bind_param($stmt, 'sss', $week_date, $crew_chief, $monday_crew);
/* Execute it */
mysqli_stmt_execute($stmt);
/* Close statement */
mysqli_stmt_close($stmt);
} // end if
这是我的 POST 数组的样子:
Array ( [0] => Array ( [week_date] => 2013-07-08 - 2013-07-14 ) [1] => Array ( [crew_chief] => Alan ) [2] => Array ( [monday_crew] => dd ) )