Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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