I am running  a query that pulls in a query string that is stored in a
field in one of my tables. Thanks to some of the people here I was
able to get the variable and the value of each part of the query
string.

<cfquery name="getSearches" datasource="ds">
 Select *
 From savedSearches
 Where sendEmail = 'yes'
</cfquery>
<cfset newList = structNew() />
<!--- Loop through Query and get key and values from querystring --->
<cfloop query="getSearches">
 <cfset eachString = arrayNew(1)>
 <cfset stringValue= arrayNew(1)>
 <cfset queryString = searchCriteria />
 <cfset eachString = listToArray(queryString , "&") />
<cfloop from="1" to="#arrayLen(eachString)#" index="i">
  <cfset stringValue=listToArray(eachString[i], "=") />
<cfif ArrayLen(stringValue) EQ 2>
<cfset structInsert(newList,stringValue[1],stringValue[2],true) />
 </cfif>
   </cfloop>

</cfloop>

Where I am stuck is that I need to run a 2nd query that matches values
in a table to the values in the stringValue array, but because those
values are in a loop and I need the query run outside the loop I
figured I would store each key and it's value in a structure.

The problem I am having is, say 2 records are returned from the
getSearches query. One record has the key "TypeHome" and the other
doesn't. The struct is adding "TypeHome" and the value of "TypeHome"
to the record that doesn't contain that key. I have a <cfif> statement
that looks to see if "TypeHome" exists and if it does  it adds a And
statement to my query but because the structInsert is always adding
"TypeHome" the query returns inaccurate results.

Anyone have a better solution for accomplishing the same thing?

Thanks,
Ben

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.houseoffusion.com/banners/view.cfm?bannerid=11

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182141
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to