经过几天的研究和反复试验后,我终于决定寻求帮助了。
我有一个带有复选框的表单,允许人们选择他们想要数据的部门。我遇到的问题是结果页面。我正在尝试显示一个表格,其中包含每个部门的数据以及相关部门的名称。相反,我得到一个表格,其中每个部门名称仅列出第一部门的数据,然后是另一个表格,每个部门名称列出,第二部门的数据仅列出,等等。
数据被发送到CFC:
<cffunction access="public" name="myQuery">
<cfif isDefined("form.departmentList") is "True">
<cfquery name="myQuery" dataSource="hqdata">
<!--- SELECT statement held in cfset --->
<cfoutput>#selectDepartmentInformation#</cfoutput>
FROM hqdata
WHERE dep IN
(<cfqueryparam cfsqltype="CF_SQL_CHAR" value="#form.departmentList#" list="yes" separator=",">)
AND loc = 'downtown'
ORDER BY dep ASC
</cfquery>
<cfelse>
<cfquery name="myQuery" dataSource="hqdata">
SELECT sectional
FROM hqdata
WHERE dep = 'none'
</cfquery>
</cfif>
<cfreturn myQuery>
departmentList是表单检查部门的内容。
<cfoutput query="myQuery">
<!--- Change the deparmentList from list to array --->
<cfset departmentListLoop = "#departmentList#">
<cfset departmentListArray = listToArray (departmentListLoop, ",",false,true)>
<!--- Where the formulas for table results. --->
<cfinclude template="tabledata.cfm">
<table>
<tr>
<td></td>
<td><strong>06</strong></td>
<td><strong>07</strong></td>
<td><strong>08</strong></td>
<td><strong>09</strong></td>
<td><strong>10</strong></td>
<td><strong>11</strong></td>
</tr>
<cfloop array="#departmentListArray#" index="i">
<tr>
<td><strong>#i#</strong></td>
<td>#round(final2006)#%</td>
<td>#round(final2007)#%</td>
<td>#round(final2008)#%</td>
<td>#round(final2009)#%</td>
<td>#round(final2010)#%</td>
<td>#round(final2011)#%</td>
</tr>
</cfloop>
</table>
</cfoutput>