I have searched far and wide for a specific case were i could get this answer but what i have seems to me like it should work. but it doesn't.
I basically want to concatenate data into a row in my database. Put simply if there is no existing data it injects the filenames variable into the row.
If there is existing data in the row i need to append a "," to the start so that i can break the filenames out later with php on my page.
Here's what i have that doesn't seem to work.
$query = "UPDATE plan
SET plan_files = if(plan_files is null,concat(plan_files,
'{$filenames}'),concat(plan_files, ',{$filenames}'))
WHERE plan_id='{$planid}'";