2013-09-26 22 views
1

我是统计教师的学生评估。我想我的结果显示为:CFLoop和ListValueCount

Instructor1 - 145 
Instructor2 - 23 
Instructor3 - 394 

#CountInstructor#没有更改。这只是第一次计数是正确的。

使用Coldfusion 8.
感谢您的帮助。

<CFQUERY NAME="GetAll" datasource="eval" dbtype="ODBC"> 
SELECT ID, Instructor, Q1, Q2, Q3, Q4, Q5, Q6 
FROM data 
</CFQUERY> 
<CFQUERY NAME="GetInstructor" datasource="eval" dbtype="ODBC"> 
SELECT DISTINCT Instructor 
FROM data 
ORDER BY Instructor 
</CFQUERY> 

<cfset myInstructor = ValueList(GetInstructor.Instructor)> 
<cfset myCountInstructor = ValueList(GetAll.Instructor)> 
<cfset CountInstructor = ListValueCount(myCountInstructor, myInstructor)> 

<cfoutput query="GetAll"> 
    <cfset CountInstructor = ListValueCount(myCountInstructor, GetInstructor.Instructor)> 
    #GetInstructor.Instructor# - #CountInstructor# <br /> 
</cfoutput> 
+0

你的问题是什么? –

+1

错误确定...那么最新的问题? – Jarede

+1

您的查询不需要'dbtype =“ODBC”'。除了'查询',dbtype的所有其他用途都被弃用。 – duncan

回答

0

在您的查询输出循环中使用ListValueCount()不会对您有任何帮助。你想要做什么?如果你正在寻找做的是输出,你去一个个性化......

<cfoutput query="GetInstructor"> 
    #GetInstructor.Instructor# - #GetInstructor.CurrentRow# 
</cfoutput> 

否则,我只是不知道你想要做什么(你需要范围内的所有变量,包括查询名称)。

+0

发现我的错误:应该是获取正确的数字 – user2525393

+0

希望教练将输出分组,使其按照OP所希望的方式工作 – Lance

0
<cfoutput query="GetInstructor"> 
    <cfset CountInstructor = ListValueCount(myCountInstructor, GetInstructor.Instructor)> 
    #GetInstructor.Instructor# - #CountInstructor# <br /> 
</cfoutput>