I fill up an array (Session.myArray) with finds users make in my database, when they hit submit I generate my query based on the values in the array :
the values in the array are
[x][1] : FieldName
[x][2] : Symbol (=, >, LIKE, <=, etc)
[x][3] : string or value entered by the user
[x][4] : 'And' OR 'Or' for next find
I get an error saying that 'The element at position 1, of dimension 2, of an array object used as part of an expression, cannot be found'
This is my code :
<cfquery name="dbname" datasource="Mydsn">
select * from dbname where 0=0
<cfloop index="x" from="1" to="#Number_Of_Finds#">
<cfif left(#Session.myArray[x][1]#,1) EQ "n" OR left(#Session.myArray[x][1]#,1) EQ "d">
<cfif #Session.myArray[x][2]# EQ "LIKE">
#Session.myArray[x][4]# #Session.myArray[x][1]# #Session.myArray[x][2]# #Session.myArray[x][3]#
<cfelse>
<cfif #Session.myArray[x][2]# EQ "NOT LIKE">
#Session.myArray[x][4]# #Session.myArray[x][1]# <> #Session.myArray[x][3]#
<cfelse>
#Session.myArray[x][4]# #Session.myArray[x][1]# #Session.myArray[x][2]# #Session.myArray[x][3]#
</cfif>
</cfif>
<cfelse>
<cfif #Session.myArray[x][2]# EQ "LIKE" OR #Session.myArray[x][2]# EQ "NOT LIKE">
#Session.myArray[x][4]# upper(trim(#Session.myArray[x][1]#)) #Session.myArray[x][2]# upper('%#Session.myArray[x][3]#%')
<cfelse>
#Session.myArray[x][4]# upper(trim(#Session.myArray[x][1]#)) #Session.myArray[x][2]# upper(#Session.myArray[x][3]#)
</cfif>
</cfif>
</cfloop>
</cfquery>
Does anybody have a answer, or maybe a less complex solution for this problem ? Any help is appreciated...
Fleer
the values in the array are
[x][1] : FieldName
[x][2] : Symbol (=, >, LIKE, <=, etc)
[x][3] : string or value entered by the user
[x][4] : 'And' OR 'Or' for next find
I get an error saying that 'The element at position 1, of dimension 2, of an array object used as part of an expression, cannot be found'
This is my code :
<cfquery name="dbname" datasource="Mydsn">
select * from dbname where 0=0
<cfloop index="x" from="1" to="#Number_Of_Finds#">
<cfif left(#Session.myArray[x][1]#,1) EQ "n" OR left(#Session.myArray[x][1]#,1) EQ "d">
<cfif #Session.myArray[x][2]# EQ "LIKE">
#Session.myArray[x][4]# #Session.myArray[x][1]# #Session.myArray[x][2]# #Session.myArray[x][3]#
<cfelse>
<cfif #Session.myArray[x][2]# EQ "NOT LIKE">
#Session.myArray[x][4]# #Session.myArray[x][1]# <> #Session.myArray[x][3]#
<cfelse>
#Session.myArray[x][4]# #Session.myArray[x][1]# #Session.myArray[x][2]# #Session.myArray[x][3]#
</cfif>
</cfif>
<cfelse>
<cfif #Session.myArray[x][2]# EQ "LIKE" OR #Session.myArray[x][2]# EQ "NOT LIKE">
#Session.myArray[x][4]# upper(trim(#Session.myArray[x][1]#)) #Session.myArray[x][2]# upper('%#Session.myArray[x][3]#%')
<cfelse>
#Session.myArray[x][4]# upper(trim(#Session.myArray[x][1]#)) #Session.myArray[x][2]# upper(#Session.myArray[x][3]#)
</cfif>
</cfif>
</cfloop>
</cfquery>
Does anybody have a answer, or maybe a less complex solution for this problem ? Any help is appreciated...
Fleer