首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CFLoop和ListValueCount

CFLoop和ListValueCount
EN

Stack Overflow用户
提问于 2013-09-27 00:25:59
回答 2查看 151关注 0票数 1

我在统计学生对教师的评价。我希望我的结果显示为:

代码语言:javascript
复制
Instructor1 -   145
Instructor2 -    23
Instructor3 -   394

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

使用Coldfusion 8。

谢谢你的帮助。

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2013-09-27 01:24:20

在查询输出循环中使用ListValueCount()对您没有任何帮助。你到底想做什么?如果你想做的就是输出一个计数...

代码语言:javascript
复制
<cfoutput query="GetInstructor">
    #GetInstructor.Instructor# - #GetInstructor.CurrentRow#
</cfoutput>

否则,我不确定您想要做什么(并且您需要确定所有变量的作用域,包括查询名称)。

票数 0
EN

Stack Overflow用户

发布于 2013-10-18 21:56:57

代码语言:javascript
复制
<cfoutput query="GetInstructor">
   <cfset CountInstructor = ListValueCount(myCountInstructor, GetInstructor.Instructor)> 
    #GetInstructor.Instructor#  - #CountInstructor# <br />
</cfoutput>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19033627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档