Outputting data in Excel
I’m exporting data to Excel. I have some outputting issue. If a user has taken a class, I would like to put an X in the cell. I have to get all the users by running the “getsUsers” query first to get be all the rows of users. Then, I would have to run “getClassesUsersHaveSignedUp4” within “getsUsers”. This unfortunatley gives me the first row of users.
I would like to display the data like this:
Users | Biology | Chemistry | Math | Phys |
Tommy | X |
| X | X |
Kim |
| X |
| X |
Sara |
|
| x |
|
<CFQUERY name="getUsers" datasource="#dsn#">
SELECT userid, class_id, name
FROM userstable
</CFQUERY>
<CFQUERY name="getClassesUsersHaveSignedUp4" datasource="#dsn#">
SELECT class_id, userid class
FROM class_junction
WHERE userid = #userid#
</CFQUERY>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">User Name</td>
<CFQUERY name="getClasses" datasource="#dsn#">
SELECT class_id, userid , class
FROM lookup_table
WHERE class_id = #class_id#
</CFQUERY>
<cfoutput query=” getClasses “>
<td valign="top"> #class#</td>
</cfoutput>
</tr>
<cfoutput query =” getUsers”>
<tr>
<td valign="top">#name#</td>
<td valign="top”> <cfif a user has taken a class> X </cfif> </td>
</tr>
</cfoutput>
</table>
