I have a $_POST array which currently takes the following form:
["Area"]=> array(2) {
[0]=> string(5) "Title"
[1]=> string(5) "Title"
}
["Issue"]=> array(2) {
[0]=> string(3) "111"
[1]=> string(7) "2222222"
}
["Elevation"]=> array(2) {
[0]=> string(8) "11111111"
[1]=> string(7) "2222222"
}
["Fix"]=> array(2) {
[0]=> string(8) "11111111"
[1]=> string(6) "222222"
}
["ExpectFee"]=> array(2) {
[0]=> string(8) "11111111"
[1]=> string(5) "22222"
}
["Outlay"]=> array(2) {
[0]=> string(9) "111111111"
[1]=> string(9) "222222222"
}
["ExpctTime"]=> array(2) {
[0]=> string(9) "111111111"
[1]=> string(11) "22222222222"
}
["Checkbox"]=> array(2) {
[0]=> string(12) "111111111111"
[1]=> string(11) "22222222222"
}
I am currently looping through it like this...
if ($_POST['OthProb']['Issue'] != '') {
$table = 'tbl_customproblems';
$kv = array();
foreach ($_POST['OthProb'] as $array) {
foreach ($array as $value) {
$kv[] = "'".$value."'";
}
$string = "INSERT INTO $table (AccountID, myID, Area, Issue, Elevation, Fix, ExpectFee, Outlay, ExpctTime, Checkbox) VALUES ('$_POST[AccountID]', '$_POST[myID]', ".join(", ", $kv).")";
}
} else {
$string = $_SERVER['QUERY_STRING'];
}
$sql = $DBH->prepare($string);
$sql->execute();
Which almost works! It produces this...
"INSERT INTO tbl_customproblems (AccountID, PropertyID, Area, Issue, Elevation, Fix, ExpectFee, Outlay, ExpctTime, WHCheckbox) VALUES ('81', '81', 'Title', 'Title', '111', '2222222', '11111111', '2222222', '11111111', '222222', '11111111', '22222', '111111111', '222222222', '111111111', '22222222222', '111111111111', '22222222222')"
How do I amend my loop to produce seperate inserts, one for each row being passed.