Question
Formatting date extracted from DB
I have a database table which holds responses from mulitiple
online questionnaires, each record represent a question and its
response. each instance of a questionnaire is represented by an
item_id.
the customer would like the data from this questionnaire to be displayed in a table format as part of a report.
the columns names in the display table correspond to the questions not the columns in the response table.
Below is the code i have tried thus far, the first block works the best but does not repeat the table structure.
the customer would like the data from this questionnaire to be displayed in a table format as part of a report.
the columns names in the display table correspond to the questions not the columns in the response table.
Below is the code i have tried thus far, the first block works the best but does not repeat the table structure.
<cfloop query="getQ75Items"> <!--- unique item ids associated with questionnaire 75 --->
<cfset row_count = row_count + 1>
<cfquery name="getQ75Response" datasource="#application.insp#">
select *
from response_tbl
Where inspection_id = #session.inspection# and questionaire_id = 75 and item_id = #getQ75Items.item_id#
</cfquery> <!--- query sets up an instance of the questionnaire --->
<!--- <cfoutput >this code block lays out the data properly, however, the table structure does not repeat
<tr >
<td><cfloop query="getQ75Response"><cfif question_id IS 1196 >#response#</cfif></cfloop></td>
<td> <cfloop query="getQ75Response"> <cfif question_id IS 1197 >#response#</cfif></cfloop></td>
<td> <cfloop query="getQ75Response"> <cfif question_id IS 1198>#response#</cfif></cfloop></td>
<td><cfloop query="getQ75Response"><cfif question_id IS 1200>#response#</cfif> </cfloop></td>
<td> <cfloop query="getQ75Response"><cfif question_id IS 1201>#response#</cfif></cfloop></td>
<td> <cfloop query="getQ75Response"><cfif question_id IS 1202>#response#</cfif></cfloop></td>
<td> <cfloop query="getQ75Response"><cfif question_id IS 1554>#response#</cfif></cfloop></td>
<td> <cfloop query="getQ75Response"><cfif question_id IS 1555>#response#</cfif> </cfloop> </td>
</tr>
</cfoutput> --->
<!--- <cfoutput >This code block "stair steps" the data between row 1 - col 1 and Row 8 - col 8 for a single record, and the table structure does not repeat
<cfloop query="getQ75Response">
<tr >
<td><cfif question_id IS 1196 >#response#</cfif></td>
<td> <cfif question_id IS 1197 >#response#</cfif></td>
<td> <cfif question_id IS 1198>#response#</cfif></td>
<td><cfif question_id IS 1200>#response#</cfif> </td>
<td><cfif question_id IS 1201>#response#</cfif></td>
<td> <cfif question_id IS 1202>#response#</cfif></td>
<td><cfif question_id IS 1554>#response#</cfif></td>
<td><cfif question_id IS 1555>#response#</cfif> </td>
</tr>
</cfloop>
</cfoutput> --->
<cfoutput query="getQ75Response">
This code block "stair steps" the data between row 1 - col 1 and Row 8 - col 8 for a single record, and the table structure does not repeat
<tr>
<td><cfif question_id IS 1196 >#response#</cfif></td>
<td> <cfif question_id IS 1197 >#response#</cfif></td>
<td> <cfif question_id IS 1198>#response#</cfif></td>
<td><cfif question_id IS 1200>#response#</cfif> </td>
<td><cfif question_id IS 1201>#response#</cfif></td>
<td> <cfif question_id IS 1202>#response#</cfif></td>
<td><cfif question_id IS 1554>#response#</cfif></td>
<td><cfif question_id IS 1555>#response#</cfif> </td>
</tr>
</cfoutput>
</table>
</cfloop>
