I'm trying to get a system where the array data is changed to match the ID of its entry on another MySQL table. I am getting this from checkboxes on a PHP script.
This is the code
$insertSQL2 = "INSERT INTO test (Testing) VALUES SELECT Course_id FROM courses WHERE Code IN ";
foreach ($_POST['CheckboxGroup1'] as $Q){
$Q = mysql_real_escape_string($Q);
$insertSQL2.= "('$Q'), ";
}
$insertSQL2 = rtrim($insertSQL2, ", ");
I can get the raw data output when I want. e.g. when the four checkboxes are selected, they will be placed in the table in seperate rows (which I require). However when I try to change it to match the code (When the checked box = a code in the table, the id is placed instead of the code) I get the following error.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'SELECT Course_id FROM courses WHERE
Code IN ('CNMD'), ('EEM')' at line 1
Has anybody got any possible solutions?