?
Solved

Combining two lists of values so I can loop through them as one list

Posted on 2003-03-26
2
Medium Priority
?
137 Views
Last Modified: 2013-12-24
I have created a form that displays a record set using the cfgrid component.  Right now, users are able to filter the list based on a single condition. For example, they can see all items with a 'Developer' value of 'Bob'. The values for Filterby (Developer) and Filtervalue (Bob) are being sent as URL variables. However, now I'm trying to allow the filter to have multiple conditions. For example, Developer='Bob' AND 'open_closed=Open'. Hence, the value for Filterby would be 'Developer, open_closed' and the value for Filtervalue would be 'Bob, Open'.  How can I combine these two lists into one structure so that I can loop through the values and set each condition in a query that I'm building on the fly based on the url variables?  Thanks in advance for your help...I'll copy the pertinent code below:

This is the URL with the variables:

index.cfm?fuseaction=InterTrack.interTrack&filterby=Developer,open_closed&filtervalue=jwhite,Open

This is the query I'm trying to build:

<CFQUERY DBTYPE="query" name="TrackerList" cachedwithin="#CreateTimeSpan(0,0,0,-1)#">
SELECT *
FROM <cfif NOT IsDefined("history")>TrackerCache<cfelse>TrackerHistory</cfif>
WHERE 0=0
<cfloop list='FilterList'>
     <CFIF (ParameterExists(Filterby) IS "Yes")>
          <cfif (Filterby IS NOT 'blank') AND (Filterby IS NOT 'Title') AND (Filterby IS NOT 'Manager') AND (Filterby IS NOT 'QA') AND (Filtervalue IS NOT 'isnull')>
               AND #Filterby# = '#filtervalue#'
          <cfelseif Filtervalue IS 'isnull'>          
               AND (#Filterby# IS NULL)
          <cfelseif Filterby IS 'Title'>
               AND #Filterby# LIKE '%#filtervalue#%'
          <cfelseif Filterby IS 'QA'>
               AND Status = 'Ready for Review' AND Reviewer = '#session.userid#'
          <cfelseif (Filterby IS 'manager') AND (session.roleID Contains 'DevManager')>
               AND Status = 'New' AND Product IN (#PreserveSingleQuotes(prodsmanaged)#)
          </cfif>
     </cfif>
</cfloop>
     ORDER BY ItemNumber
</CFQUERY>
0
Comment
Question by:sloap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
TallerMike earned 500 total points
ID: 8211052
Try something like this instead:

        ?filterby=Developer~jwhite,open_closed~Open

url.filter will return this:

        Developer~jwhite,open_closed~Open

Then you'll want to loop through url.filter like so:

<cfloop list="#url.filter#" index="filterNameValue">
  <cfset filterName = GetToken(filterNameValue,1,"~">
  <cfset filterValue = GetToken(filterNameValue,2,"~">
</cfloop>
0
 

Author Comment

by:sloap
ID: 8211155
Thanks TallerMike...that was exactly what I was looking for and it worked fabulously...
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question