Solved

display list of states, with list of projects under each state

Posted on 2014-10-02
2
115 Views
Last Modified: 2014-10-02
ColdFusion 9
MS SQL Server 2012

I should know this, and have done this before, but can't think of the solution right now.

On this page: http://www.doivista.org/oursites.cfm

I need to display a list of states, with a list of projects under each state. Right now, the states are not grouped.

Here's the code, below. Thanks as always. =)

Eric

<cfquery name="getProjects" datasource="#application.datasource#">
SELECT
projectID,
ProjectName,
OSMVISTA,
State,
Archive
FROM #REQUEST.ProjectsTable#
ORDER BY State, ProjectName, Archive
</cfquery>


<!--- Loop through project data records --->
 <cfoutput query="getProjects" group="state">
 
 <cfloop query="getProjects">
<p><strong>#getProjects.State#</strong></p>
<p><a href="/showProjectRecord.cfm?ProjectID=#val(getProjects.ProjectID)#">#getProjects.ProjectName#</a> (OSM/VISTA Volunteer: #getProjects.OSMVISTA#)</p>
</cfloop>

 </cfoutput>

Open in new window

0
Comment
Question by:Eric Bourland
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40357193
The "State" header should be within the outer loop. Also, use <cfoutput> instead of <cfloop> for the inner loop.  

Untested, but something like this:
<!--- Loop through project data records --->
 <cfoutput query="getProjects" group="state">
     <p><strong>#getProjects.State#</strong></p>
 
      <cfoutput>
         <p>
              <a href="/showProjectRecord.cfm?ProjectID=#val(getProjects.ProjectID)#">#getProjects.ProjectName#</a> (OSM/VISTA Volunteer: #getProjects.OSMVISTA#)
        </p>
     </cfoutput>

 </cfoutput>

Open in new window

0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 40357204
Got it. =)

_agx_, thank you as always. Hope your day is going well.

Take care. =)

Eric
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now