I have a form that is passing values like this.
When its not 0 I would like to get
that specific record from a query
select * from table
where ID = '#number#'
Do you mean something like this?:
<cfif form.GETL639NAVY neq 0>
WHERE ID = <cfqueryparam value="#form.GETL639NAVY#" CFSQLType='CF_SQL_INTEGER'>
that would be for that specific variable.
But for all variables
'GET....' if the variable is not equal to 0
then i would like it to find the record in the table which is the ID
<!--- List of all form fields --->
<cfset formFieldList = form.fieldnames>
<cfloop list="#formFieldList#" index="formField">
<cfif left(formfield,3) is "get" and isNumeric(form[formfield]) and form[formfield] is not 0><!--- Field-name begins with "get" and field value is a number other than 0--->
<cfquery name="#formfield#Query"><!---Distinguish dynamically between the queries --->
WHERE ID = <cfqueryparam value="#form[formfield]#" CFSQLType='CF_SQL_INTEGER'>