I have a table memberships.
I supply my user with a text box, in which there is a list of the current emails in memberships. They can edit the list. Once they send the list back, I want to update memberships so it only contain emails that are in the list the user supplied.
The best way I can think of is just to delete all emails and just insert the whole list back in. Is there a better method?
What I am doing now:
$mysql->query('DELETE FROM memberships');
$userEmails = explode('\n', $_POST['users']);
foreach ($userEmails as $email)
$mysql->query('INSERT INTO memberships (email) VALUES (?)', $email);
Something like this maybe are what you are looking for (untested). Dont forget to escape your input before using in querys to prevent sql injections.