April 4th, 2013, 04:57 PM
Join Date: Mar 2007
Time spent in forums: 4 Days 20 h 39 m
Reputation Power: 7
Pdo update checkboxlist in mysql
Ok, hopefully I can explain where I am stuck.
Here is my situation:
I have a mysql database and 3 tables.
- contact (containing a contact_id and more)
- event_manager (containing event_id and more)
- contact_events (containing contact_id and event_id)
When I insert a new contact using php pdo, and I check several checkboxes in the checkboxlist I get the value from $_POST['eventlist'], than I take the contact_id (just created) and add it to the contact_events table linked to an event_id. (every event is on a new row).
conact_id - event_id
The insert works.
But now when I want to update the contact and change several of the checkboxes in the checkboxlist. The new values need to be added to the table, but the events not checked anymore need to be removed from the table (meaning the whole row).
I know that when I use $_POST only the checked checkboxes are being passed but I have no idea on how to remove unchecked events.
Does anyone has an idea on how to solve this.
Please help me with an example.