Solved

outputing one file to a file at a time.

Posted on 2006-06-14
5
149 Views
Last Modified: 2013-12-24
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"><strong>Vendor Code</strong></td>
            <td nowrap style="font-size:8pt"><strong>Vendor Name</strong></td>
            <td nowrap style="font-size:8pt"><strong>Address</strong></td>
            <td nowrap style="font-size:8pt"><strong>State</strong></td>
            <td nowrap style="font-size:8pt"><strong>City</strong></td>
            <td nowrap style="font-size:8pt"><strong>Country Code</strong></td>
            <td nowrap style="font-size:8pt"><strong>Postal Code</strong></td>
            <td nowrap style="font-size:8pt"><strong>Phone</strong></td>
            <td nowrap style="font-size:8pt"><strong>Tax ID Number</strong></td>
            <td nowrap style="font-size:8pt"><strong>Tax Code</strong></td>
            <td nowrap style="font-size:8pt"><strong>Expense 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">#vendor_code#</td>
                  <td nowrap style="font-size:8pt">#address_name#</td>
                  <td nowrap style="font-size:8pt">#addr1# #addr2# #addr3#</td>
                  <td nowrap style="font-size:8pt">#state#</td>
                  <td nowrap style="font-size:8pt">#city#</td>
                  <td nowrap style="font-size:8pt">#country_code#</td>
                  <td nowrap style="font-size:8pt">#postal_code#</td>
                  <td nowrap style="font-size:8pt">#contact_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>
0
Comment
Question by:DancingFighterG
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:aseusainc
ID: 16907473
Change the way you build #record# and get rid of all the &'s.

<cfset record = "#record##addr1# #addr2# #addr3#,">
0
 
LVL 7

Accepted Solution

by:
aseusainc earned 30 total points
ID: 16907515
You can build it all on one line if you like as well...

<cfif store_output eq "Yes" and lven NEQ vendor_code >
<cfset record = "#vendor_code#,#address_name#,#addr1# #addr2# #addr3#,#state#,#city#,#country_code#,#postal_code#,#contact_phone#,#tax_id_num#,#tax_code#,#exp_acct_code#">
<cfset lven = cven>
</cfif>


0
 

Author Comment

by:DancingFighterG
ID: 16907836
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.
0
 
LVL 7

Expert Comment

by:aseusainc
ID: 16907861
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.
0
 

Author Comment

by:DancingFighterG
ID: 16907872
Cool, thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now