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.&nbsp; I am having a =
problem with=20
some code I wrote.&nbsp; What I am trying to do is update a record that =
has=20
multiple different records (rows)&nbsp; with one field that is in =
common.&nbsp;=20
unfortunately, the number of records that can be present is variable =
(think of=20
it like ingredients in a recipe. . .)&nbsp;I can add a new set just =
fine, but if=20
I want to edit them, what happens is&nbsp;all the records are =
overwritten by the=20
last record in the set when I try to change anything.&nbsp; I haven't =
even=20
gotten to adding or removing ingredients yet.&nbsp; here is the code for =
the=20
action page:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;!--- Update all the preexisting =
information.=20
---&gt;<BR>&nbsp;&nbsp;&lt;cfquery name=3D"qcfgetNumberOfIngredients"=20
datasource=3D"FSLibraryTest"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;SELECT&nbsp;&=
nbsp;MIN(IngredientID)=20
as firstIngredient, MAX(IngredientID) as=20
lastINgredient<BR>&nbsp;&nbsp;&nbsp;FROM&nbsp;&nbsp;tblRecipeIngredient<B=
R>&nbsp;&nbsp;&nbsp;WHERE&nbsp;&nbsp;RecipeID=3D#form.RecipeID#<BR>&nbsp;=
&nbsp;&nbsp;&lt;/cfquery&gt;<BR>&nbsp;<BR>&lt;!---=20
This loop is the same as the one on FSERecipeEditIngredients.&nbsp; It =
grabs the=20
number of ingredients for this particular recipe, =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;and uses the number to update each of the preexisting =
ingredients=20
---&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;cfloop index=3DX=20
from=3D#qcfgetNumberOfIngredients.firstIngredient#=20
to=3D#qcfgetNumberOfIngredients.lastINgredient#&gt;<BR>&nbsp;&nbsp;&nbsp;=
&nbsp;&lt;cfset=20
updateMeasurement=3DEvaluate("form.IngredientMeasurement" &amp;=20
X)&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;cfset=20
updateDescription=3DEvaluate("form.IngredientDescription" &amp;=20
X)&gt;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&lt;cfquery=20
name=3D"qcfdoInternalIngredientUpdate"=20
datasource=3D"FSLibraryTest"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;UPDATE&nbsp;&=
nbsp;tblRecipeIngredient<BR>&nbsp;&nbsp;&nbsp;&nbsp;SET&nbsp;&nbsp;&nbsp;=
IngredientMeasurement=3D'#updateMeasurement#',=20
IngredientDescription=3D'#updateDescription#'<BR>&nbsp;&nbsp;&nbsp;&nbsp;=
WHERE&nbsp;&nbsp;RecipeID=3D#form.RecipeID#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
<BR>&nbsp;&nbsp;&nbsp;&lt;/cfquery&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/cfloop&g=
t;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>here is the code that I am using to =
display the=20
record:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;cfquery =
name=3D"qcfgetNumberOfIngredients"=20
datasource=3D"FSLibraryTest"&gt;<BR>&nbsp;&nbsp;SELECT&nbsp;&nbsp;MIN(Ing=
redientID)=20
as firstIngredient, MAX(IngredientID) as=20
lastINgredient<BR>&nbsp;FROM&nbsp;&nbsp;tblRecipeIngredient<BR>&nbsp;WHER=
E&nbsp;&nbsp;RecipeID=3D#url.RecipeID#<BR>&nbsp;&lt;/cfquery&gt;</FONT></=
DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;cfform =
name=3D"addNewIngredientsToRecipe"=20
method=3D"POST"=20
action=3D"FSERecipeingredientuploadaction.cfm?RecipeID=3D#url.RecipeID#"&=
gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;cfloop index=3DX=20
from=3D#qcfgetNumberOfIngredients.firstIngredient#=20
to=3D#qcfgetNumberOfIngredients.lastINgredient#&gt;<BR>&nbsp;&lt;cfset=20
queryName=3DEvaluate(DE("qcfgetIngredientsToEdit" &amp; =
X))&gt;<BR>&nbsp;&lt;cfset=20
firstVariableToDisplay=3DEvaluate(DE(queryName &amp;=20
Evaluate(DE(".IngredientMeasurement"))))&gt;<BR>&nbsp;&lt;cfset=20
secondVariableToDisplay=3DEvaluate(DE(queryName &amp;=20
Evaluate(DE(".IngredientDescription"))))&gt;<BR>&nbsp;&lt;cfset=20
firstHiddenVariable=3DEvaluate(DE(queryName &amp;=20
Evaluate(DE(".IngredientID"))))&gt;<BR>&nbsp;<BR>&nbsp;&lt;cfquery=20
name=3D"#queryName#"=20
datasource=3D"FSLibraryTest"&gt;<BR>&nbsp;&nbsp;SELECT&nbsp;&nbsp;Ingredi=
entID,=20
RecipeID, IngredientMeasurement,=20
IngredientDescription<BR>&nbsp;&nbsp;FROM&nbsp;&nbsp;tblRecipeIngredient<=
BR>&nbsp;&nbsp;WHERE&nbsp;&nbsp;IngredientID=3D#x#<BR>&nbsp;&lt;/cfquery&=
gt;<BR>&nbsp;<BR>&nbsp;&lt;cfoutput&gt;<BR>&nbsp;&lt;tr&gt;<BR>&nbsp;&nbs=
p;&lt;td&gt;&lt;cfinput=20
type=3D"text" name=3D"IngredientMeasurement#x#" size=3D"15"=20
value=3D#Evaluate(firstVariableToDisplay)#&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;i=
nput=20
type=3D"hidden" name=3D"IngredientID#x#"=20
value=3D"#Evaluate(firstHiddenVariable)#"&lt;/td&gt;<BR>&nbsp;&nbsp;&lt;t=
d&gt;&lt;cfinput=20
type=3D"text" name=3D"IngredientDescription#x#" size=3D"45"=20
value=3D#Evaluate(secondVariableToDisplay)#&gt;&lt;/td&gt;<BR>&nbsp;&lt;/=
tr&gt;<BR>&nbsp;&lt;/cfoutput&gt;<BR>&nbsp;<BR>&lt;/cfloop&gt;</FONT></DI=
V>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry about the length of this post, =
but this one=20
has me kinda stumped.&nbsp; It probably something absurdly easy that i =
will slap=20
my head as soon as its pointed out to me.&nbsp; ^_^</FONT></DIV>
<DIV>&nbsp;</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.

Reply via email to