basically I have a field that stores a series of IDs of images (separated by commas)
eg:
400,12,4,12 etc
when the user adds an image into the DB, a new ID is inserted into that field:
-if the field is empty or null, the ID is inserted normally;
-if there's something already in that field, a comma and then the ID are inserted
my query I use is:
UPDATE albums
SET images_list=IF(images_list IS NULL OR images_list = '', '$image_id', CONCAT(images_list,',$image_id'))
WHERE album_id=$album_id