I have my array displayed like it but I cant seems to be able to save it into database. So when I do var_dump($result);
while $result is my array then the following content is displayed
array
0 =>
array
'Credit Weighting' => string '5' (length=1)
'Teaching Period(s)' => string 'Teaching Periods 1 and 2.' (length=25)
'No. of Students' => string '-.' (length=2)
1 =>
array
'Credit Weighting' => string '5' (length=1)
'Teaching Period(s)' => string 'Teaching Periods 1 and 2.' (length=25)
'No. of Students' => string '-.' (length=2)
2 =>
array
'Credit Weighting' => string '10' (length=2)
'Teaching Period(s)' => string 'Teaching Periods 1 and 2.' (length=25)
'No. of Students' => string '-.' (length=2)
And below is my PDO query to save the above content into mysql but nothing is happening.What am I doing wrong please ??
$result = array();
$placeholder = array();
$values = "?, ?, ?";
foreach ($result as $array){
$placeholder[] = $value;
$result[] = $array['CreditWeighting'];
$result[] = $array['TeachingPeriod'];
$result[] = $array['NoofStudents'];
}
$sql = "INSERT INTO data_array_copy (CreditWeighting,TeachingPeriod,NoofStudents)
VALUES (". implode('), (', $placeholder) . ")";
$stmt = $conn->prepare($sql);
$stmt->execute($result);