Solved

Looping and checking the previous row for a value in a loop?

Posted on 2006-06-16
2
167 Views
Last Modified: 2013-12-24
Hi,

I am trying to work with this recordset and cant recall how to do this.  Each record has a date, but when looping over the records if the date in the currentRow is equal to the date in the previous row, then don't show a date.  This should be very easy to do.  I just cant recall the correct syntax for doing so.

I have a query that I am looping over and each record has a "date" so:

DATE          STATE
04/10/06     CA
04/10/06     OR
04/15/06     FL
04/18/06     WY


If you notice above, the date 04/10/06 appears twice.  I only want the date to appear once if it is the same so it should be like:

DATE          STATE
04/10/06     CA
                  OR
04/15/06     FL
04/18/06     WY

There must be a way to take the currentRow's date value and then look at the previous row and if its the same, make it blank.

-ws
0
Comment
Question by:Westside2004
2 Comments
 
LVL 9

Accepted Solution

by:
73Spyder earned 175 total points
ID: 16923153
Easiest way would be to set a temp variable

<cfset variables.temp_value = "">
<cfoutput query="your_data">
     <cfif your_data.date NEQ variables.temp_value >
             display date here
     </cfif>
   // - Rest of data here


<cfset variables.temp_value = your_data.date>
</cfoutput>

This should displat the date the first time it appears in the recordset but skip other rows
0
 
LVL 1

Author Comment

by:Westside2004
ID: 16923536
Worked... thanks

-ws
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

24 Experts available now in Live!

Get 1:1 Help Now