Answered
**repost**adding <cfloop> contents to a structure key
Another question in regards to an earlier post with the same
name that Mr. Bracuk helped me with. Relevant information again.
I am trying create a structure which contains all the dates of a particular event inside of its elements. A visual representation would look like: EventID:Day1:2008-02-01
Day2:2008-02-02
Day3:2008-02-03.
My query:
<CFQUERY datasource="#sDSN#" name="qEvents">
SELECT event_id,
event_startdate,
event_enddate
from hs_event
</CFQUERY>
My code:
<!--- Populate the event structure by running a loop that will go from the startdate listed in the event_startdate column and go to the hs_event_enddate column, incrementing by 1 for each "day" between these 2 dates.--->
<cfset ObjEvents = structNew()>
<CFOUTPUT>
<CFLOOP query="qEvents">
<CFSET ObjEvents[currentrow] = qEvents.event_id>
<cfset ThisDate = event_startdate[currentrow]>
<cfset nCounter = 1>
<CFLOOP condition="ThisDate LTE event_enddate[currentrow]">
<CFSET nCounter = nCounter + 1>
<CFSET ThisDate = DateAdd("d", 1, ThisDate)>
</CFLOOP>
</CFLOOP>
</CFOUTPUT>
Mr. Bracuk got me this far. But, I am not at all familiar with the CFSCRIPT tag, and only slightly familiar with the nature of structures <very, very new to programming>. I am assuming from my reading that I need to nest an EventsID structure inside the ObjEvents structure that I have created, and from there, elements that have named value pairs of Day1 = ActualDay. I truly appreciate your help! Dan
I am trying create a structure which contains all the dates of a particular event inside of its elements. A visual representation would look like: EventID:Day1:2008-02-01
Day2:2008-02-02
Day3:2008-02-03.
My query:
<CFQUERY datasource="#sDSN#" name="qEvents">
SELECT event_id,
event_startdate,
event_enddate
from hs_event
</CFQUERY>
My code:
<!--- Populate the event structure by running a loop that will go from the startdate listed in the event_startdate column and go to the hs_event_enddate column, incrementing by 1 for each "day" between these 2 dates.--->
<cfset ObjEvents = structNew()>
<CFOUTPUT>
<CFLOOP query="qEvents">
<CFSET ObjEvents[currentrow] = qEvents.event_id>
<cfset ThisDate = event_startdate[currentrow]>
<cfset nCounter = 1>
<CFLOOP condition="ThisDate LTE event_enddate[currentrow]">
<CFSET nCounter = nCounter + 1>
<CFSET ThisDate = DateAdd("d", 1, ThisDate)>
</CFLOOP>
</CFLOOP>
</CFOUTPUT>
Mr. Bracuk got me this far. But, I am not at all familiar with the CFSCRIPT tag, and only slightly familiar with the nature of structures <very, very new to programming>. I am assuming from my reading that I need to nest an EventsID structure inside the ObjEvents structure that I have created, and from there, elements that have named value pairs of Day1 = ActualDay. I truly appreciate your help! Dan
