cfloop. cfbreak

Experts,

I have this code below that doesn't seem to be working correctly.  This data is getting spit out into a table, and whenever I have students that did not answer any questions, I am expecting a '0', but instead getting a blank row.  If a student looks at a question, but doesn't answer we send this string to the database "noag^tasktime~2.00"  What I think is happening is when the <cfset matchFound = 1> it does break the loop because it is simply looking to see if something is in the database for this student.  I didn't write this code, and I'm not sure how to get around this.  If anyone has any suggestions, it would be greatly appreciated.  

The code.....
<cfoutput query="getstudent">
    <cfset s = s +1>
    <tr>
      <th align="left" scope="row" style="white-space:nowrap; ">#getstudent.lastName#, #getstudent.firstName#</th>
      <td align="right">#NumberFormat(studentCorrectPercentage[s], '99')#%</td>
      <cfloop index="j" list="#gettestlet.includedItems#" delimiters=",">
        <!--- this loop compare the items answered with the whole list items, if there is no answer, fill 0, otherwise indicate correct or not --->
        <cfloop index="k" from="1" to="#ArrayLen(itemsAnsweredForEachStudent[s])#">
          <cfif itemsAnsweredForEachStudent[s][k] eq j>
            <td align="center" class="item_mark"><cfif studentPerformanceOnEachItem[s][k] eq 1>
                C
                <cfelse>
                X
              </cfif>
              <!---cfoutput>#studentPerformanceOnEachItem[s][k]#</cfoutput--->
            </td>
            <cfset matchFound = 1>
            <cfbreak>
            <cfelse>
            <cfset matchFound = 0>
          </cfif>
        </cfloop>
        <cfif matchFound eq 0>
          <td align="center" class="item_mark"> O </td>
        </cfif>
      </cfloop>
    </tr>
  </cfoutput>
LVL 2
nmaranoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
Not sure if this will do it, but if the array length of itemsAnsweredForEachStudent
in this line:
<cfloop index="k" from="1" to="#ArrayLen(itemsAnsweredForEachStudent[s])#">
is zero (there are no answers?)  then you will not process any of the code below it.

I suggest moving the matchFound = 0 before the loop instead of in the CFELSE statement so you can handle any time the arrayLen is 0.

See the attached code..
<cfoutput query="getstudent">
    <cfset s = s +1>
    <tr>
      <th align="left" scope="row" style="white-space:nowrap; ">#getstudent.lastName#, #getstudent.firstName#</th>
      <td align="right">#NumberFormat(studentCorrectPercentage[s], '99')#%</td>
      <cfloop index="j" list="#gettestlet.includedItems#" delimiters=",">
        <cfset matchFound = 0> <!--- assume no match, in case array len is 0 --->
        <cfloop index="k" from="1" to="#ArrayLen(itemsAnsweredForEachStudent[s])#">
          <cfif itemsAnsweredForEachStudent[s][k] eq j>
            <td align="center" class="item_mark">
			  <cfif studentPerformanceOnEachItem[s][k] eq 1>
                C
              <cfelse>
                X
              </cfif>
            </td>
            <cfset matchFound = 1>
            <cfbreak>
          </cfif>
        </cfloop>
        <cfif matchFound eq 0>
          <td align="center" class="item_mark"> O </td>
        </cfif>
      </cfloop>
    </tr>
  </cfoutput>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nmaranoAuthor Commented:
Maria-
As always, thanks for the help.  Very much appreciated
-Nick
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.