![]() |
![]() |
||||||
|
|||||||
| Tags: loop, query |
![]() |
|
|||
|
I have an access database table that contains a column that I would change all
the values to the same variable. The table is forever being populated with more rows as data is entered regularly. I have tried numerous attempts to build an insert query inside cfloop tags and I never seem to get the right result. Here is a snipet. <cfif FORM.Updated IS "no"> <CFLOOP INDEX="Update" LIST="#FORM.Updated#"> <CFQUERY Name="#Update#" DataSource="#db#"> INSERT INTO QTYTracking (Updated) VALUES ('#FORM.Updated#')</CFQUERY></CFLOOP> </cfif> |
| Sponsored Links |
|
|||
|
chrispilie wrote:
> AH... Lazy copy and paste error. The UPDATE worked. Time for some coffee! I presume that means you correct your INSERT|UPDATE logic so that you get a different value each loop? Because in your original post, the logic would produce the same value for every record put|changed in the database. <CFLOOP INDEX="Update" LIST="#FORM.Updated#"> <CFQUERY Name="#Update#" DataSource="#db#"> INSERT INTO QTYTracking (Updated) VALUES ('#FORM.Updated#')</CFQUERY></CFLOOP> </cfif> If form.Updated equaled the list 'red,white,blue' Then three values would be put into the database, but the 'Updated' column of all three would equal 'red,white,blue'. I would usually expect a loop like this to put three separate values and thus it would look something like this. <CFLOOP INDEX="Update" LIST="#FORM.Updated#"> <CFQUERY Name="#Update#" DataSource="#db#"> INSERT INTO QTYTracking (Updated) VALUES ('#Update#')</CFQUERY></CFLOOP> </cfif> But maybe that is not the desired result. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise