XenoPhage Posted March 9, 2006 Share Posted March 9, 2006 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted March 9, 2006 Share Posted March 9, 2006 A simpler solution, removing all the need for testingGet the current values so you can display themDelete all currentvalues from dbLet user change selectionWrite new selection back to db Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.