Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Help dynamically build the table in coldfusion

I have a list of courses,(which is dynamic rign now 2 courses but could be more). I Nedd to check the completion for that courses and output it into the HTML table. First i am trying to loop through the courses and get the completion, and then output it into the table

But unfortunately it did not work
 

lcourse is list of courses
<cfloop from="1" to="#ListLen(lcourse)#" index="i">
	<!---	<cfset qName="checkCompletion" &i>--->
			<cfquery name="qName" datasource="cfelsunrise" dbtype="ODBC">
				Select completiondate from EmployeeTraining where EmployeeID=#EmployeeID# and courseID in (#lcourse#)
			</cfquery>
 
	</cfloop>
	<cfloop from="1" to="#ListLEn(lcourse)#" index="i">
	<td align="center" width="2%" <cfif qName.completiondate is not "">bgcolor="##00FF00"<cfelse>bgcolor="##FF0000"</cfif>></td>
	
	</cfloop>
	</tr>
	
	</cfoutput>

Open in new window

0
erikTsomik
Asked:
erikTsomik
1 Solution
 
JillofallTradesMistressofNoneCommented:
Hi.   Where is your opening cfcoutput tag?  Is it just not in this code sample?  Check out this page for help on cfloops and output:  http://www.quackit.com/coldfusion/tutorial/coldfusion_loops.cfm

Good luck!
0
 
adobe116Commented:
Hey, I think you want to delete lines 7 and 8.  You should only loop through the list once.

Also, instead of checking to see if something equals "", simply check if it's length is > zero.

I changed that in your code.  Best of luck.
<cfoutput>
<table>
<tr>
<cfloop from="1" to="#ListLen(lcourse)#" index="i">
	<!---	<cfset qName="checkCompletion" &i>--->
	<cfquery name="qName" datasource="cfelsunrise" dbtype="ODBC">
	Select 
		completiondate 
	from 
		EmployeeTraining 
	where 
		EmployeeID = #EmployeeID#
		and
		courseID in (#lcourse#)
	</cfquery>
 
	<td align="center" width="2%" <cfif len(qName.completiondate)>bgcolor="##FF0000"<cfelse>bgcolor="##00FF00"</cfif>>#yourContent#</td>
</cfloop>
</tr>
</table>
</cfoutput>

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now