This is a multi-part message in MIME format.
------=_NextPart_000_000F_01BFFEE7.088508E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Good afternoon. I am having a problem with some code I wrote. What I =
am trying to do is update a record that has multiple different records =
(rows) with one field that is in common. unfortunately, the number of =
records that can be present is variable (think of it like ingredients in =
a recipe. . .) I can add a new set just fine, but if I want to edit =
them, what happens is all the records are overwritten by the last record =
in the set when I try to change anything. I haven't even gotten to =
adding or removing ingredients yet. here is the code for the action =
page:
<!--- Update all the preexisting information. --->
<cfquery name=3D"qcfgetNumberOfIngredients" =
datasource=3D"FSLibraryTest">
SELECT MIN(IngredientID) as firstIngredient, MAX(IngredientID) as =
lastINgredient
FROM tblRecipeIngredient
WHERE RecipeID=3D#form.RecipeID#
</cfquery>
=20
<!--- This loop is the same as the one on FSERecipeEditIngredients. It =
grabs the number of ingredients for this particular recipe,=20
and uses the number to update each of the preexisting ingredients =
--->
<cfloop index=3DX from=3D#qcfgetNumberOfIngredients.firstIngredient# =
to=3D#qcfgetNumberOfIngredients.lastINgredient#>
<cfset updateMeasurement=3DEvaluate("form.IngredientMeasurement" & =
X)>
<cfset updateDescription=3DEvaluate("form.IngredientDescription" & =
X)>
=20
<cfquery name=3D"qcfdoInternalIngredientUpdate" =
datasource=3D"FSLibraryTest">
UPDATE tblRecipeIngredient
SET IngredientMeasurement=3D'#updateMeasurement#', =
IngredientDescription=3D'#updateDescription#'
WHERE RecipeID=3D#form.RecipeID# =20
</cfquery>
</cfloop>
here is the code that I am using to display the record:
<cfquery name=3D"qcfgetNumberOfIngredients" =
datasource=3D"FSLibraryTest">
SELECT MIN(IngredientID) as firstIngredient, MAX(IngredientID) as =
lastINgredient
FROM tblRecipeIngredient
WHERE RecipeID=3D#url.RecipeID#
</cfquery>
<cfform name=3D"addNewIngredientsToRecipe" method=3D"POST" =
action=3D"FSERecipeingredientuploadaction.cfm?RecipeID=3D#url.RecipeID#">=
<cfloop index=3DX from=3D#qcfgetNumberOfIngredients.firstIngredient# =
to=3D#qcfgetNumberOfIngredients.lastINgredient#>
<cfset queryName=3DEvaluate(DE("qcfgetIngredientsToEdit" & X))>
<cfset firstVariableToDisplay=3DEvaluate(DE(queryName & =
Evaluate(DE(".IngredientMeasurement"))))>
<cfset secondVariableToDisplay=3DEvaluate(DE(queryName & =
Evaluate(DE(".IngredientDescription"))))>
<cfset firstHiddenVariable=3DEvaluate(DE(queryName & =
Evaluate(DE(".IngredientID"))))>
=20
<cfquery name=3D"#queryName#" datasource=3D"FSLibraryTest">
SELECT IngredientID, RecipeID, IngredientMeasurement, =
IngredientDescription
FROM tblRecipeIngredient
WHERE IngredientID=3D#x#
</cfquery>
=20
<cfoutput>
<tr>
<td><cfinput type=3D"text" name=3D"IngredientMeasurement#x#" =
size=3D"15" value=3D#Evaluate(firstVariableToDisplay)#>
<input type=3D"hidden" name=3D"IngredientID#x#" =
value=3D"#Evaluate(firstHiddenVariable)#"</td>
<td><cfinput type=3D"text" name=3D"IngredientDescription#x#" =
size=3D"45" value=3D#Evaluate(secondVariableToDisplay)#></td>
</tr>
</cfoutput>
=20
</cfloop>
Sorry about the length of this post, but this one has me kinda stumped. =
It probably something absurdly easy that i will slap my head as soon as =
its pointed out to me. ^_^
Chris Martin
[EMAIL PROTECTED]
FSEnablers
www.fsenablers.com
------=_NextPart_000_000F_01BFFEE7.088508E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3105.105" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Good afternoon. I am having a =
problem with=20
some code I wrote. What I am trying to do is update a record that =
has=20
multiple different records (rows) with one field that is in =
common. =20
unfortunately, the number of records that can be present is variable =
(think of=20
it like ingredients in a recipe. . .) I can add a new set just =
fine, but if=20
I want to edit them, what happens is all the records are =
overwritten by the=20
last record in the set when I try to change anything. I haven't =
even=20
gotten to adding or removing ingredients yet. here is the code for =
the=20
action page:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><!--- Update all the preexisting =
information.=20
---><BR> <cfquery name=3D"qcfgetNumberOfIngredients"=20
datasource=3D"FSLibraryTest"><BR> SELECT &=
nbsp;MIN(IngredientID)=20
as firstIngredient, MAX(IngredientID) as=20
lastINgredient<BR> FROM tblRecipeIngredient<B=
R> WHERE RecipeID=3D#form.RecipeID#<BR> =
</cfquery><BR> <BR><!---=20
This loop is the same as the one on FSERecipeEditIngredients. It =
grabs the=20
number of ingredients for this particular recipe, =
<BR> =20
and uses the number to update each of the preexisting =
ingredients=20
---><BR> <cfloop index=3DX=20
from=3D#qcfgetNumberOfIngredients.firstIngredient#=20
to=3D#qcfgetNumberOfIngredients.lastINgredient#><BR> =
<cfset=20
updateMeasurement=3DEvaluate("form.IngredientMeasurement" &=20
X)><BR> <cfset=20
updateDescription=3DEvaluate("form.IngredientDescription" &=20
X)><BR> <BR> <cfquery=20
name=3D"qcfdoInternalIngredientUpdate"=20
datasource=3D"FSLibraryTest"><BR> UPDATE &=
nbsp;tblRecipeIngredient<BR> SET =
IngredientMeasurement=3D'#updateMeasurement#',=20
IngredientDescription=3D'#updateDescription#'<BR> =
WHERE RecipeID=3D#form.RecipeID# =
<BR> </cfquery><BR> </cfloop&g=
t;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>here is the code that I am using to =
display the=20
record:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><cfquery =
name=3D"qcfgetNumberOfIngredients"=20
datasource=3D"FSLibraryTest"><BR> SELECT MIN(Ing=
redientID)=20
as firstIngredient, MAX(IngredientID) as=20
lastINgredient<BR> FROM tblRecipeIngredient<BR> WHER=
E RecipeID=3D#url.RecipeID#<BR> </cfquery></FONT></=
DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><cfform =
name=3D"addNewIngredientsToRecipe"=20
method=3D"POST"=20
action=3D"FSERecipeingredientuploadaction.cfm?RecipeID=3D#url.RecipeID#"&=
gt;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><cfloop index=3DX=20
from=3D#qcfgetNumberOfIngredients.firstIngredient#=20
to=3D#qcfgetNumberOfIngredients.lastINgredient#><BR> <cfset=20
queryName=3DEvaluate(DE("qcfgetIngredientsToEdit" & =
X))><BR> <cfset=20
firstVariableToDisplay=3DEvaluate(DE(queryName &=20
Evaluate(DE(".IngredientMeasurement"))))><BR> <cfset=20
secondVariableToDisplay=3DEvaluate(DE(queryName &=20
Evaluate(DE(".IngredientDescription"))))><BR> <cfset=20
firstHiddenVariable=3DEvaluate(DE(queryName &=20
Evaluate(DE(".IngredientID"))))><BR> <BR> <cfquery=20
name=3D"#queryName#"=20
datasource=3D"FSLibraryTest"><BR> SELECT Ingredi=
entID,=20
RecipeID, IngredientMeasurement,=20
IngredientDescription<BR> FROM tblRecipeIngredient<=
BR> WHERE IngredientID=3D#x#<BR> </cfquery&=
gt;<BR> <BR> <cfoutput><BR> <tr><BR> &nbs=
p;<td><cfinput=20
type=3D"text" name=3D"IngredientMeasurement#x#" size=3D"15"=20
value=3D#Evaluate(firstVariableToDisplay)#><BR> <i=
nput=20
type=3D"hidden" name=3D"IngredientID#x#"=20
value=3D"#Evaluate(firstHiddenVariable)#"</td><BR> <t=
d><cfinput=20
type=3D"text" name=3D"IngredientDescription#x#" size=3D"45"=20
value=3D#Evaluate(secondVariableToDisplay)#></td><BR> </=
tr><BR> </cfoutput><BR> <BR></cfloop></FONT></DI=
V>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Sorry about the length of this post, =
but this one=20
has me kinda stumped. It probably something absurdly easy that i =
will slap=20
my head as soon as its pointed out to me. ^_^</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Chris Martin</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A></FONT></D=
IV>
<DIV><FONT face=3DArial size=3D2>FSEnablers</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"http://www.fsenablers.com">www.fsenablers.com</A></FONT></DIV></B=
ODY></HTML>
------=_NextPart_000_000F_01BFFEE7.088508E0--
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.