Solved

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

Posted on 2014-10-02
2
113 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achievā€¦
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authoriā€¦
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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