<!--- Query for displaying the institutions, city, and state. --->
<cfquery name="GetResults" datasource="datasheet">
SELECT compName, City
FROM CompLocation
WHERE (Class = 'M' OR Class = 'S')
ORDER BY compName
</cfquery>
<html>
<head>
<title>IMBA</title>
</head>
<body>
<!--- Build table for results --->
<table align="center"
cellspacing="2"
cellpadding="2"
border="8"
frame="border">
<!--- Display column headings --->
<th bgcolor="#ffa500">Company Name</th>
<th bgcolor="#ffa500">City</th>
<!--- Alternate color in rows --->
<cfset colorRow = 1>
<cfoutput query="GetResults" group="compName">
<tr>
<td bgcolor="<cfif colorRow MOD 2 EQ 0>##ffa500<cfelse>##FFFFFF</cfif>">
<!--- Display company name with hyperlink if applicable --->
<cfquery name="GetURL" datasource="datasheet">
SELECT compURL
FROM CompLocation
WHERE compName = compName FROM GetResults
AND compURL IS NOT NULL
</cfquery>
<cfif compURL is not "">
<a href="compURL">#compName#</a>
<cfelse>
<b>#compName#</b>
</cfif>
</td>
<td align="center" bgcolor="<cfif colorRow MOD 2 EQ 0>##ffa500<cfelse>##FFFFFF</cfif>">
<!--- Display all cities for each company --->
<cfset cityNum = 0>
<cfset cityList = "">
<cfoutput>
<!--- If a city is listed more than once for one company, only show city once in table --->
<cfif not listFindNoCase(cityList,City)>
<cfset cityList = listAppend(cityList,City)>
</cfif>
</cfoutput>
<!--- Create a variable for the list of cities --->
<cfset loopLen = listLen(#cityList#)>
<!--- Loop cities into appropriate cells seperated by a "," --->
<cfloop from = "1" to = "#loopLen#" index = "thisCity">
#listGetAt(cityList, thisCity)#
<cfif thisCity neq listLen(#cityList#)>
,
</cfif>
<cfif thisCity Mod 3 eq 0>
<br>
</cfif>
</cfloop>
</tr>
<!--- Increment counter --->
<cfset colorRow = colorRow+1>
</cfoutput>
</table>
</body>
</html>