Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Dynamically Build MySQL Update String
Old 05-21-2011, 12:35 PM Dynamically Build MySQL Update String
Yak Yak Yak Yak Yak

Posts: 593
Location: Rochester, MN
Trades: 0
Let's say I have a form populated with data pulled from a database. If someone overwrites one of the fields and clicks "submit", the script compares each piece of data with the original, and determines which values have changed.

That's where I could use some help. I can see two options.

1. Submit an update query to update all fields, even the ones that didn't change. That would make it appear that all fields were updated, and make it hard to determine what was changed, and when.

2. Create a dynamic update query that only includes the items updated.

I think option 2 would be best, but I am not sure how to build a dynamic update query that only includes "changed" values.

I have looked around the web, and cannot find any answers. I probably don't know the correct verbiage to type into a search engine.

Would someone be willing to provide me with some direction, or point me to some resources where I can find the answer myself?
__________________

Please login or register to view this content. Registration is FREE
neorunner is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-21-2011, 12:47 PM Re: Dynamically Build MySQL Update String
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Add hidden fields for each entry box and toggle them between false/true or 0/1 with javascript using the onchange event.

then test for the field having been changed before concatenating the query.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-21-2011, 03:34 PM Re: Dynamically Build MySQL Update String
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
One could just select the data again after the form is submitted, and then compare the form data to the data from the DB.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Dynamically Build MySQL Update String
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13889 seconds with 12 queries