Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2008
    Thanked 0 Times in 0 Posts

    Help with updating a DB after changes

    suppose I have a site where a person can choose a car and some colors. A user enters the following information:

    mustang - red
    mustang - blue
    mustang - green
    mustang - orange

    On the same website, there is a form that allows a user to update their previous choices. So a few days later the same user makes the following changes to their selection:

    mustang - red
    mustang - blue
    mustang - black

    I'm curious as to what you think would be the best way to code something like this to update the mysql DB. I want the red and blue to not change. The green and orange needs to be deleted. Black needs to be added.

    I understand the core logic itself. But I'm getting hung up on the best way to streamline some code for this. Bunch of ifs? Case statement? Any ideas would be great because you'll probably spark something that I'm just not feeling right now.


  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    This may be the "lazy" way to do it (i.e. more processing time but coding is simple), but I would DELETE all of that user's previous entries and INSERT the new settings. I doubt anyone would ever notice the extra time it takes (unless the user has hundreds of settings).


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts