<cfloop index="x" from="1" to="300"> <cfif isdefined("form.update#x#") or isdefined("form.delete#x#")> <cfset form.updatenum = "#x#"> <cflock timeout="5" throwontimeout="No" name="#session.sessionID#" type="EXCLUSIVE"> <cfquery name="change" datasource="olivers" dbtype="ODBC"> UPDATE menu SET menuitem='#form.item##updatenum#', addinfo='#form.info##updatenum#', price='#form.price##updatenum#' WHERE ID = '#form.updatenum#' </cfquery> </cflock> </cfif> </cfloop> my problem is that i need to make something like this '#(#form.item#)(#updatenum#)#' to go into query but i dont know the proper syntax. this is where it is calling from <cfoutput Query="getdata2"><p class="standardtxt"> Item Title: <cfinput type="text" name="item#ID#" visible="true" value="#menuitem#" maxlength="300" width="300" size="50"><br> Extra info: <cfinput type="text" name="info#ID#" visible="true" value="#addinfo#" maxlength="300" width="300" size="40"><br> Item Cost: <cfinput type="text" name="price#ID#" visible="true" value="#price#" maxlength="300" width="300" size="5"><br> <strong> <cfinput name="update#ID#" type="submit" value="Update" /> </strong> <cfinput name="delete#ID#" type="submit" value="Delete" /> <br></p><br> <cfinput type="hidden" name="ID" value="#ID#"> </cfoutput> and it dispalys alot and i need to be able to update them now this not the only way i have tried it i think i am missing a small easy step that i dont now how to do so any help would to great thanks in advance or for just for having a look.
You can use evaluate(dynamicVariable) ie: <cfset form = structNew() /> <cfset form.item1 = "one" /> <cfset form.item2 = "two" /> <cfset form.item3 = "three" /> <cfset form.item4 = "four" /> <cfset form.item5 = "five" /> <cfloop index="x" from="1" to="5"> <cfset item2="form.item#x#"> <cfoutput>#evaluate(item2)#<br /></cfoutput> </cfloop>
sorry you must have misunderstood me but thanks for the reply. i have tried to explain myself a little better too.
Yep like I said evaluate: <cfset instertData = "form.item#updatenum#" /> <cfset instertinfo = "form.info#updatenum#" /> thing use this to insert: UPDATE menu SET menuitem='#evaluate(instertinfo)#', addinfo='#evaluate(instertData)#', ice='#form.price##updatenum#' WHERE ID = '#form.updatenum#' Also you should use cfqueryparam
You can, but you should avoid using evaluate unless it is really necessary. In most cases it is not. Use associative array notation. Not tested, but here is the idea: UPDATE menu SET menuitem = '#form["item"& updatenum]#' .... You should also use cfqueryparam on all query parameters.
thanks i got it woking i ended up having a simple error thanks for the help this is what worked best UPDATE menu SET menuitem='#form["item"& updatenum]#', addinfo='#form["info"& updatenum]#', price='#form["price"& updatenum]#' WHERE ID = #form.updatenum# im very greatfull for the help