what you want to do is this (i think):
$arr = array($tw_deep, $tw_eyelashes, $tw_holistic, $tw_male_nail);
$arrPlode = implode(', ', $arr);
$db->query("INSERT INTO checked_treatments (treatment_group, id_treatment, id_booking, b_ref)
VALUES('$arrPlode', '1','$id_bookslot', '$b_ref')");
here is a demo with a query echo: http://codepad.org/3NgGu1Tm
OR
make a new query for each if:
if(!empty($bookslot['t_deep'])) {
$db->query("INSERT INTO checked_treatments (treatment_group, id_treatment, id_booking, b_ref)
VALUES('deep_wrap', '1','$id_bookslot', '$b_ref')");
}
if(!empty($bookslot['t_eyelashes'])) {
$db->query("INSERT INTO checked_treatments (treatment_group, id_treatment, id_booking, b_ref)
VALUES('eyeLashes_wrap', '1','$id_bookslot', '$b_ref')");
}
if(!empty($bookslot['t_holistic'])) {
$db->query("INSERT INTO checked_treatments (treatment_group, id_treatment, id_booking, b_ref)
VALUES('holistic_wrap', '1','$id_bookslot', '$b_ref')");
}
if(!empty($bookslot['t_male_nail'])) {
$db->query("INSERT INTO checked_treatments (treatment_group, id_treatment, id_booking, b_ref)
VALUES('male_nail_wrap', '1','$id_bookslot', '$b_ref')");
}
OR CONCATENATE THE QUERIES:
$concat = array();
if(!empty($bookslot['t_deep'])) {
$concat[] = "('deep_wrap', '1','$id_bookslot', '$b_ref')";
}
if(!empty($bookslot['t_eyelashes'])) {
$concat[] = "('eyeLashes_wrap', '1','$id_bookslot', '$b_ref')";
}
if(!empty($bookslot['t_holistic'])) {
$concat[] = "('holistic_wrap', '1','$id_bookslot', '$b_ref')";
}
if(!empty($bookslot['t_male_nail'])) {
$concat[] = "('male_nail_wrap', '1','$id_bookslot', '$b_ref')";
}
$db->query(build_insert_query('checked_treatments',
'treatment_group, id_treatment, id_booking, b_ref', $concat));
function build_insert_query($table, $cols, $values){
$return = "INSERT INTO $table ($cols) VALUES";
$val_length = count($values);
foreach($values as $key=>$val){
$return .= $val;
if($key < ($val_length-1)){ $return .= ", "; }
}
return $return;
}
here is a demo of the above with fake values: http://codepad.org/ox4kG43b