I am building gallery with categories and having problem with this subject.
Only 2 tables. 1st table has categories
Second table has photos data. Second table has category_id from 1st table. Pretty simple...
now when i delete the category i would like to update 2nd table with category_id = NULL ot = ''. Is it possible ?
I tried using triggers but no success yet. getting syntax errors...
$sql = "
CREATE TRIGGER update_gal_items AFTER DELETE ON gallery_category
FOR EACH ROW
BEGIN
UPDATE gallery_photos SET photo_category='' WHERE photo_category=$id;
END
";
Any help please ?