That looks good....Im still having a nightmare getting it to update properly in the first place though :(
Here's what's going on....
Admin selects a user profile to edit, on that page is the record from the users table along with a multiple select of all departments from the departments table. Now by this point I've already done a select from the staff allocation table to get the names of the departments they currently work for and so these are pre-selected.
So say we have departments 1 2 3 4 5 and Staff Member A works for 1 2 3 then on the profile page it would show:
1 Selected
2 Selected
3 Selected
4
5
Now if admin decides to add department 4 I need the code to skip 1 2 3 (as this is already in the database) and insert the 4th department into the staff allocation table. Vice versa....if department 3 is removed for example I need to skip 1 and 2 and then deactivate 3.
I can't get this to work at all :(
Here's what's going on....
Admin selects a user profile to edit, on that page is the record from the users table along with a multiple select of all departments from the departments table. Now by this point I've already done a select from the staff allocation table to get the names of the departments they currently work for and so these are pre-selected.
So say we have departments 1 2 3 4 5 and Staff Member A works for 1 2 3 then on the profile page it would show:
1 Selected
2 Selected
3 Selected
4
5
Now if admin decides to add department 4 I need the code to skip 1 2 3 (as this is already in the database) and insert the 4th department into the staff allocation table. Vice versa....if department 3 is removed for example I need to skip 1 and 2 and then deactivate 3.
I can't get this to work at all :(