have a page that is supposed to loop through a set of results and create an rtf document for each returned record. But it is currently only creating one rtf document, and it's for the first record. Does anyone know how to change my code so it creates a document for each result. Preferrably, all documents would be created with in the same rtf...that is each document is a page long, and for each result, a new page would be created within the same rtf document. But seperate documents would work too.
Here's the code:
<cfset contact_list = form.contact_id>
<cffile action="read" file="\\devweb01\inetpub\zone.specialtyrisk.com\application\contact\questionnaire\q_print.rtf" variable="RTF">
<cfloop list="#contact_list#" index="i">
<cfquery name="contact_info" datasource="#application.datasource#">
SELECT dob, cert_number, ssn, f_name, l_name
FROM sri_contact.dbo.contact_cob_questionnaire
WHERE contact_id = #i#
</cfquery>
<cfset rtf = replace(RTF,"%dob%",contact_info.dob)>
<cfset rtf = replace(RTF,"%cert_num%",contact_info.cert_number)>
<cfset rtf = replace(RTF,"%ssn%%",contact_info.ssn)>
<cfset rtf = replace(RTF,"%f_name%",contact_info.f_name)>
<cfset rtf = replace(RTF,"%l_name%",contact_info.l_name)>
<cfheader name="Content-Type" VALUE="application/rtf">
<cfheader name="Content-Disposition" value="attachment; filename=q_print.rtf">
<cfcontent type="application/rtf"><cfoutput>#RTF#</cfoutput>
</cfloop>
Here's the code:
<cfset contact_list = form.contact_id>
<cffile action="read" file="\\devweb01\inetpub\zone.specialtyrisk.com\application\contact\questionnaire\q_print.rtf" variable="RTF">
<cfloop list="#contact_list#" index="i">
<cfquery name="contact_info" datasource="#application.datasource#">
SELECT dob, cert_number, ssn, f_name, l_name
FROM sri_contact.dbo.contact_cob_questionnaire
WHERE contact_id = #i#
</cfquery>
<cfset rtf = replace(RTF,"%dob%",contact_info.dob)>
<cfset rtf = replace(RTF,"%cert_num%",contact_info.cert_number)>
<cfset rtf = replace(RTF,"%ssn%%",contact_info.ssn)>
<cfset rtf = replace(RTF,"%f_name%",contact_info.f_name)>
<cfset rtf = replace(RTF,"%l_name%",contact_info.l_name)>
<cfheader name="Content-Type" VALUE="application/rtf">
<cfheader name="Content-Disposition" value="attachment; filename=q_print.rtf">
<cfcontent type="application/rtf"><cfoutput>#RTF#</cfoutput>
</cfloop>