I have a 1 dimensional array of strings ($answers). I want to store each string as a new record a long with an itemId (the same itemId for each answer) into my table "answers_tb".
I have tried.....
using a foreach to construct a new array 2 dimensional array, with the $answers array and the itemID and then imploding this new array into my query.
not working.
i get this error:
Column count doesn't match value count at row 1
here is my code:
$records = array();
foreach($answers as $item_id => $text_value) {
$records[] = '("' . $item_id . '","' . $text_value . '")';
}
$sql = "INSERT INTO answers_tb (item_id, text_value) VALUES('" . implode(',', $records)." ')";
mysql_query($sql) or die(mysql_error());
many thanks for getting this far, even if you cant help.
regards,