I'm trying to build an array that will give me all values from my list and then based on the records from the cfquery I wan to get values for years. To make this more clear I will show you below how my array should look like:
time slot year2015 year 2016
0700 0 0
0715 1 0
0730 0 0
0745 0 0
0800 0 5
and so on. My time slot values are stored in <cfset dataList>
and that looks like this:
<cfloop list="#ListGetAt(dataList,i,",")#" index="k" delimiters="|">
<cfoutput>#k#</cfoutput>
</cfloop>
0600 0615 0630 0645 0700 0715 0730 0745 0800 0815 0830 0845 0900 0915 0930 0945 1000 1015 1030 1045 1100 1115 1130 1145 1200 1215 1230 1245 1300 1315 1330 1345 1400 1415 1430 1445 1500 1515 1530 1545 1600 1615 1630 1645 1700 1800 1900 2000 2100 2200 2300 0000
My time slot, years and values for each year are outputted from cfquery that looks like this:
<cfoutput query="getRecords" group="YearRecord">
<cfoutput>
#TimeSlot# - #YearRecord# - #ValueYear#<br/>
</cfoutput>
</cfoutput>
0830 - 2015 - 2
0915 - 2015 - 2
1000 - 2015 - 1
0630 - 2016 - 1
0800 - 2016 - 1
My records are coming from two different locations. Time slots from my list and records with valid values from my cfquery. So I want to build my array that contains all records from my list and for each record I want to output year column with the valid value. So I tried first to populate my array with the elements from the list:
<cfset myArray=ArrayNew(1)>
<cfloop list="#ListGetAt(dataList,i,",")#" index="z" delimiters="|">
<cfoutput>
#myArray[z]#
</cfoutput>
</cfloop>
and this code give me an error:
Type: Expression ********** Line: 253 ********** ********** The element at position 600 of dimension 1, of array variable "MYARRAY," cannot be found.
Also after I populate array I would have to add two more elements to that array. Year and values for each year. If anyone knows what I'm doing wrong and what is the best way to do this please let me know. Thanks in advance.