Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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