Trying something new (to me) here.
First I build a multidimensional array using some form post values. Let's assume numdays here equals 2:
$multieventarr = Array();
for($i=0; $i<$numdays; $i++){
$values = Array();
$multieventdate = clean($_POST['eventDate_'.$i.'']);
$multistarttime = clean($_POST['startTime_'.$i.'']);
$multiendtime = clean($_POST['endTime_'.$i.'']);
$multistarttime24 = date("H:i", strtotime($multistarttime));
$multiendtime24 = date("H:i", strtotime($multiendtime));
array_push($values, $multieventdate);
array_push($values, $multistarttime24);
array_push($values, $multiendtime24);
array_push($multieventarr, $values);
}
From this I get the following, which I dump just prior to attempting the insert to make sure I have values:
array(2) {
[0]=> array(3) {
[0]=> string(10) "2018/08/30"
[1]=> string(5) "00:00"
[2]=> string(5) "01:00"
}
[1]=> array(3) {
[0]=> string(10) "2018/08/31"
[1]=> string(5) "01:00"
[2]=> string(5) "02:00"
}
}
Then I try to insert the values as follows:
for($i=0; $i<$numdays; $i++){
$qry = "INSERT INTO cae_event_dates(eventid, eventdate, starttime, endtime)VALUES('$eventid', '{$multieventarr[$i][0]}', '{$multieventarr[$i][1]}', '{$multieventarr[$i][2]}')";
$conn->exec($qry);
}
Thanks to Nigel for the original suggestion to add curly braces around the array vars in the VALUES section of the insert statement. This worked for me, as the screen capture shows.
I didn't change anything else, so not sure how or why the database accepts what I am giving it without performing some of the formatting suggestions mentioned here, but it worked.
Cheers!