DancingFighterG
asked on
outputing one file to a file at a time.
Hello, I'm trying to print of of each line from a query that I am doing into a file but the problem that I am having is that it keeps giving me one of a line multiple times. I tried using a comparision to see if I could set a standard for when to not copy but I'm not to familiar with how the cfloop works. Can someone help me with this. Here is my code for the printing part:
<!-- Display Data -->
<cfif isDefined("submit")>
<cfif #qry_vendor.recordCount# eq "0">
<h3>No records found matching your criteria.</h3>
<cfabort>
</cfif>
<table border = "0">
<tr><td height = "15"></td></tr>
<!-- Data Headers -->
<tr>
<td nowrap style="font-size:8pt"><str ong>Vendor Code</strong></td>
<td nowrap style="font-size:8pt"><str ong>Vendor Name</strong></td>
<td nowrap style="font-size:8pt"><str ong>Addres s</strong> </td>
<td nowrap style="font-size:8pt"><str ong>State< /strong></ td>
<td nowrap style="font-size:8pt"><str ong>City</ strong></t d>
<td nowrap style="font-size:8pt"><str ong>Countr y Code</strong></td>
<td nowrap style="font-size:8pt"><str ong>Postal Code</strong></td>
<td nowrap style="font-size:8pt"><str ong>Phone< /strong></ td>
<td nowrap style="font-size:8pt"><str ong>Tax ID Number</strong></td>
<td nowrap style="font-size:8pt"><str ong>Tax Code</strong></td>
<td nowrap style="font-size:8pt"><str ong>Expens e Acct</strong></td>
</tr>
<!-- Loop through the Data -->
<cfset lven = "">
<cfloop query = "qry_vendor">
<tr>
<cfset cven = 'vendor_code'>
<td nowrap style="font-size:8pt">#ven dor_code#< /td>
<td nowrap style="font-size:8pt">#add ress_name# </td>
<td nowrap style="font-size:8pt">#add r1# #addr2# #addr3#</td>
<td nowrap style="font-size:8pt">#sta te#</td>
<td nowrap style="font-size:8pt">#cit y#</td>
<td nowrap style="font-size:8pt">#cou ntry_code# </td>
<td nowrap style="font-size:8pt">#pos tal_code#< /td>
<td nowrap style="font-size:8pt">#con tact_phone #</td>
<td nowrap style="font-size:8pt">#tax _id_num#</ td>
<td nowrap style="font-size:8pt">#tax _code#</td >
<td nowrap style="font-size:8pt">#exp _acct_code #</td>
</tr>
<cfif store_output eq "Yes" and lven NEQ vendor_code >
<cfset record = record & vendor_code & delimiter>
<!---- <cfset record = record & address_name & delimiter>
<cfset record = record & addr1 & addr2 & addr3 & delimiter>
<cfset record = record & state & delimiter>
<cfset record = record & city & delimiter>
<cfset record = record & country_code & delimiter>
<cfset record = record & postal_code & delimiter>
<cfset record = record & contact_phone & delimiter>
<cfset record = record & tax_id_num & delimiter>
<cfset record = record & tax_code & delimiter>
<cfset record = record & exp_acct_code & delimiter> ----->
<cfset lven = cven>
</cfif>
<cfif store_output eq "Yes">
<CFFILE ACTION="APPEND" FILE="#file#" OUTPUT="#record#" ADDNEWLINE="Yes">
</cfif>
</cfloop>
</cfif>
</table>
</cfoutput>
<!-- Display Data -->
<cfif isDefined("submit")>
<cfif #qry_vendor.recordCount# eq "0">
<h3>No records found matching your criteria.</h3>
<cfabort>
</cfif>
<table border = "0">
<tr><td height = "15"></td></tr>
<!-- Data Headers -->
<tr>
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
<td nowrap style="font-size:8pt"><str
</tr>
<!-- Loop through the Data -->
<cfset lven = "">
<cfloop query = "qry_vendor">
<tr>
<cfset cven = 'vendor_code'>
<td nowrap style="font-size:8pt">#ven
<td nowrap style="font-size:8pt">#add
<td nowrap style="font-size:8pt">#add
<td nowrap style="font-size:8pt">#sta
<td nowrap style="font-size:8pt">#cit
<td nowrap style="font-size:8pt">#cou
<td nowrap style="font-size:8pt">#pos
<td nowrap style="font-size:8pt">#con
<td nowrap style="font-size:8pt">#tax
<td nowrap style="font-size:8pt">#tax
<td nowrap style="font-size:8pt">#exp
</tr>
<cfif store_output eq "Yes" and lven NEQ vendor_code >
<cfset record = record & vendor_code & delimiter>
<!---- <cfset record = record & address_name & delimiter>
<cfset record = record & addr1 & addr2 & addr3 & delimiter>
<cfset record = record & state & delimiter>
<cfset record = record & city & delimiter>
<cfset record = record & country_code & delimiter>
<cfset record = record & postal_code & delimiter>
<cfset record = record & contact_phone & delimiter>
<cfset record = record & tax_id_num & delimiter>
<cfset record = record & tax_code & delimiter>
<cfset record = record & exp_acct_code & delimiter> ----->
<cfset lven = cven>
</cfif>
<cfif store_output eq "Yes">
<CFFILE ACTION="APPEND" FILE="#file#" OUTPUT="#record#" ADDNEWLINE="Yes">
</cfif>
</cfloop>
</cfif>
</table>
</cfoutput>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Man, that makes me so angry that it was so much easier than what I was doing. thanks you. one more thing, is there anyway within this that I can format it where each value is in a seperate colum. I'm exporting the file in excel.
The above code is comma delimited. Just save it as a .txt file and open it with Excel. Excel will open up a wizard that will let you confirm the columning.
ASKER
Cool, thank you!
<cfset record = "#record##addr1# #addr2# #addr3#,">