Search code examples
coldfusioncoldfusion-9cfml

Displaying CFQuery Result Over Time Span


I'm able to get query's over a time span of say 1hr - in 15 minute increments...

I am just trying to stop displaying repetitive result when the Primary Key is the same.

ie: If something starts at 6:45am - and ends at 8:00am - I only want it to span the DIV once if the primary key (masterid) is the same. And then if something else is at 8am with a different primary key - to span that div time frame etc...

I am contemplating a cfloop or the like - checking that the mastered is either the same or different/

Thoughts on how to do this...

Query code working fine - as is my display code... Image included to give idea of what I'm trying to do.

Output

    <cfloop index="incr" from="0" to="#loopreps#">
    <cfoutput>

    Loopreps is thru the time spans of 15 mins...

     <cfquery name="scht" datasource="#ds#">
 Proper Query
 </cfquery>

    <cfif scht.recordcount is not 0>
    <cfset mid = #scht.masterid#>
    This is where I am lost to hold it to only 1 result when spanning time


    Proper Display Across Div Height Span once if MasterID is same

    </cfif>

   </cfoutput>
   </cfloop>

Solution

  • I usually put a garbage value before starting a loop.

    <cfset CompareValue = "value that will never occur in real life">
    <cfloop>
    <cfif FieldToCheck is not CompareValue>
    <cfset CompareValue = FieldToCheck>
    more code
    <cfelse>
    appropriate code, maybe nothing
    </cfif>
    </cfloop>