Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:28:58+00:00 2026-05-28T04:28:58+00:00

I have a table memberships . I supply my user with a text box,

  • 0

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:28:58+00:00Added an answer on May 28, 2026 at 4:28 am

    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.

    $userEmails = explode("\n", mysql_real_escape_string($_POST['users']));
    $mysql->query("DELETE FROM `memberships` WHERE `email` NOT IN ('".implode("','", array_values($userEmails))."');");
    $mysql->query("REPLACE INTO `memberships` (`email`) VALUES ('".implode("'),('", array_values($userEmails)).");");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the models User and Group, and the join table Membership which uses
Does anyone out there have a create script for aspnet_membership table? I found a
I have 3 tables: people, groups and memberships. Memberships is a join table between
I have a Users model that can have many Groups through Memberships. If a
I have a Rails 2.3 app which tracks an organisation's members, and whether they
I want to represent clubs which have multiple members (each member can also join
I have a mysql table with my users... each user has various attributes like
I have a table which links to another table in the ASP.NET membership schema.
I have Memberships and Bookings tables in a database containing an attribute cust_id, which
I have a basic Users / Memberships / Groups I want a user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.