473,372 Members | 1,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Updating selected options Logic

can some help me with a problem?

Here are my tables: User, Profiles, and one for "Profiles per user"

In the last one, I save the ID of the user and the ID of the profiles for that user. This profiles are selected through checkboxes. My question is, What's the best way to update the records on the database?,
because there's three scenarios, they selected a new profile (INSERT), they leave like it was (NOTHING), or they unselected a profile (DELETE).

But I can't figure out a "nice" way to do this. Should I just erase all the records from the table, and then insert all the new ones even if there are unchaged records?,
Any ideas?
Mar 17 '08 #1
3 1248
2,878 Expert 2GB
This would mean there can be multiple profiles per user.

Why don't you just add a ProfileStatus field that you can just change to 0 for Inactive simulating a DELETE and 1 for active simulating an INSERT or a reactivation of a profile.

For me, this would take 2 steps. INSERT those that are not yet on the profile and activate those SELECTED (if the record is currently selected it will overwrite the same value - which is 1).

-- CK
Mar 18 '08 #2
Assuming that you want a user to have many profiles, there is more than one way to do this.

The user presses "Save", and their information is deleted from the database, and the new information saved. This is the option you have mentioned.

The user presses "Save". The code (eg .NET) checks for profiles that have been marked as "Delete", and deletes them. The code checks for profiles that have been added, and adds them. The code then updates the rest.

There is a "Save" button on each Profile line on the screen, and the user saves after each change. This will make it easier for you to manage, but I guess it depends how many changes the user makes at one time. They might get sick of pressing the "Save" button after a while.

There is no right answer here. They are all valid choices. Personally, I would either go for option one and make sure I wrapped it in a transaction in case something went wrong half way through, or go for option two.

Hope this helps
Mar 19 '08 #3
Ok, Thanks! I just want to use the option that gives me the best performance gain.
seeing this options I think I'll try option number two.

Thanks again
Mar 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
by: Raffi | last post by:
Hi folks, I'm new to JavaScript and need some help. I have a form with a select field. Depending on what is selected in this field, I want to display or not display another select field. For...
by: smash2004 | last post by:
I want to keep selected values in select list when i click on another option...with a click on a mouse... if i have 3 options in select list and i click first option..it gets selected..if i then...
by: webmaster | last post by:
I have a form that is using HTML and PHP to make calculations for an order form. One of the fields is asking for a total number of workstations. I would like this field to be a real-time total of...
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form...
by: rsteph | last post by:
I've got an option group with 5 options, with no default value. Whenever I open the form and scroll through records all of the options are grey'd, unless the user selects one. What I would like to...
by: yasminussain | last post by:
Hi to all, I have written one jsp file. In that file, I have one drop down which contains list of request name (like student name) based on the selected value within drop down I will display the...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.