CFIF识别答案列表 - 通过答案列表循环

时间:2014-02-04 16:40:52

标签: sql coldfusion coldfusion-9

如果答案列表中包含所有“N / A”(不适用)响应,我有点遗失。如果是这样 - 我希望它显示“All Chosen as NOT Applicable”

如果所有答案都是N / A,则下面的代码有效 - 但如果答案中有“是”或“否”。它也可能显示All Chosen为NOT NOTable note ...

我认为这是我的第一个CFLOOP,我需要确保它被正确设置为所有不适用的......但它不会首先通过所有查询答案...如果它遇到了不适用它会坚持一个不适用于那里......

大脑伤害试图修复......可能是愚蠢而简单的事情......

<cfquery name=qlist datasource="#mhhds#">
    select * from question where catid = #catid# and specific = 0
    order by catid
</cfquery>

<cfloop query=qlist>
    <cfquery name="anslist" datasource="#mhhds#">
        select * from Answer where inspid = #inspid# and qid = #qid#
        order by qid
    </cfquery>

    <cfparam name="ansnotna" default="">
    <cfif anslist.answer contains "yes" or anslist.answer contains "no">
        <cfset ansnotna = "yes">
    <cfelse>
        <cfset ansnotna = "na">
    </cfif>
</cfloop>

<cfif ansnotna is "na">
    <div class="nalist">
        <span  class=verd10>All Chosen As Not Applicable</span>
    </div>
</cfif>


<cfloop query=qlist>
    <cfquery name="anslist" datasource="#mhhds#">
        select * from Answer where inspid = #inspid# and qid = #qid#
        order by qid
    </cfquery>

    <cfif anslist.answer is Not "N/A">
        Show N/A Stuff
    </cfif>

    <cfif anslist.answer is "Yes">
        Show Yes Stuff
    </cfif>

    <cfif anslist.answer is "No">
        Show No Stuff
    </cfif>
</cfloop>

得到它排序...每次创建一个列表和附加列表... 如果它包含是或否 - 它不能是“所有不适用”

      <cfset alist = "">

      <cfloop query=qlist>
      <cfquery name="anslist" datasource="#mhhds#">
      select * from Answer where inspid = #inspid# and qid = #qid#
      order by qid
      </cfquery>

      <cfset alist = ListAppend(alist, "#anslist.answer#", ",")>

      </cfloop>

      <cfparam name="nalist" default="yes">
      <cfif alist contains "yes" or alist contains "no">
      <cfset nalist = "no">
      </cfif>

      <cfif nalist is "yes">
      <div class="nalist">
      <span  class=verd10>
      All Chosen As Not Applicable
      </span>
      </div>

0 个答案:

没有答案