CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Updating multiple rows using a record form?

Print topic Send  topic

Author Message
paulmason411


Posts: 127
Posted: 06/16/2008, 6:55 PM

Hi guys,

I have a bunch of check boxes in a record form that each correspond to a different row in my database.

Can anyone suggest the best way to customise the update? Cheers.
_________________

http://paulmason.name - Web Development Blog

View profile  Send private message
wkempees


Posts: 1679
Posted: 06/17/2008, 1:41 PM

Can you explain some more what you intend to do?

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
paulmason411


Posts: 127
Posted: 06/17/2008, 4:53 PM

Okay sure, I'll try using an example:

  
ID   userID  foodID preference  
1      12       1        1  
2      12       4        0  
3      12       5        1  
4      12       7        0  

So thats the table i want to insert into. In my form I have checkboxes linked to each of those foodID's and depending on if they are ticked or not a row needs to be inserted with the preference indicating the checkboxes boolean value. I am able to insert and display, i'm just not sure how to update.

please let me know if this is too confusing? Thanks.

_________________

http://paulmason.name - Web Development Blog

View profile  Send private message
wkempees


Posts: 1679
Posted: 06/18/2008, 4:19 AM

Ok, eventhough it still is a mystery to me, I have this advice for you:
You state you know how to Insert and Display.
You need to know how to update.
I assume you have created your own INSERT code.
change the INSERT (only the word) into REPLACE.
That way the adtabase will handle an INSERT with already existing key values as an UPDATE.
But, will INSERT any non existing key values.
I assume your key to be a compound key (userID, FoodID.
Before you do this, show us ( a piece) of the event in which you do the INSERT.

HTH
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
paulmason411


Posts: 127
Posted: 06/23/2008, 5:33 PM

Hey Walt,

I wasn't using a compound key originally, but i have changed it and used REPLACE. It now works perfectly. Thanks.

Here is my insert and replace code for anyone else having the same problem i had.

  
INSERT INTO customer_cuisines(customerID, cuisineID, preference)   
VALUES({UserID},1,{chk_asian}),  
({UserID},2,{chk_italian}),  
({UserID},3,{chk_australian}),  
({UserID},4,{chk_french}),  
({UserID},5,{chk_indian}),  
({UserID},6,{chk_spanish}),  
({UserID},7,{chk_general})  

  
REPLACE INTO customer_cuisines(customerID, cuisineID, preference)   
VALUES({UserID},1,{chk_asian}),  
({UserID},2,{chk_italian}),  
({UserID},3,{chk_australian}),  
({UserID},4,{chk_french}),  
({UserID},5,{chk_indian}),  
({UserID},6,{chk_spanish}),  
({UserID},7,{chk_general})  

_________________

http://paulmason.name - Web Development Blog

View profile  Send private message
wkempees


Posts: 1679
Posted: 06/23/2008, 5:45 PM

Well done!


Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.