I have a list of checkboxes on a form, which updates the user’s status.
I want to do like, when new users are selected in the checkbox, then they get inserted in DB, otherwise, if something is unchecked, but it is active in the database, then it should be deactivated.
I adopted:
I took 2 arrays, first from database, where I get which users are active.
And second from the submitted form, which values are checked, but don’t know how I will calculate that which data to be inserted and which one should be made inactive?
Loop through the ones in the database and if they are not checked by the user then remove them.
Then loop through the ones checked by the user and if they are not in the database add them.