Jump to content

Algorithm Question


XenoPhage

Recommended Posts

Hey all,

I have a select multiple box. In that box are a number of options. The user chooses options and then the back end saves them to a database. This all works fine.

Now, the user needs to edit those choices. I pull the data from the database, and display the relevant selections to the customer. Again, that same select multiple box, but this time with the previous selections highlighted. The customer changes the selection and submits it again.

This is the part I'm curious about. Right now, I take that input, plus the values from the database, and I build a hash. If the value is in the database *and* was submitted, I do nothing. If the value is in the database and not submitted, I delete it from the database. And lastly, if it was submitted but not in the database, I add it to the database.

My question is, is there a more efficient way to do this? Are there any tricks or php functions that can do this work easily? The code is fairly simple to do this, but I think I'm wasting a ton of memory because, in the end, I wind up with 3 lists that have roughly the same data depending on how many changes there were..

Any thoughts?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.