CFFILE output multiple rows from a query

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Re: CFFILE output multiple rows from a query

    I have a quiestion about the below. I am working with this method, but I find
    that my code results in the first record being outputed twice in the document.
    How can I resolve that? And I can not just leave a blank line at the top (that
    will screw things up further into what I am doing).

    My code is attached:

    <cffile action="WRITE" file="#adrdir#\sfiles.dat" output="#Dirlist.Name#">
    <cfloop query="Dirlist">
    <cffile action="APPEND" file="#adrDir#\sfiles.dat" output="#Dirlist.Name#">
    </cfloop>

    robstacey Guest

  2. Similar Questions and Discussions

    1. DBI Query rows Benchmark
      Hello! I have a questionto those lovers of DBI and Databases: which method is faster to know the number of rows of a query: $sth->rows or ...
    2. Multiple output from singe search query
      I have a search page that searches a database table of technical articles on a computer support site. In the table, there are bit columns for...
    3. Generating table rows and columns in output?
      When I output the query results, I would like to display them in a 4 column table. While I can have it add a column as cell as in...
    4. Query problem with multiple records output
      ABERDEEN, , GB ABERDEEN, MD, US ABERDEEN, MS, US ABERDEEN, NC, US ABERDEEN, SD, US ABERDEEN, WA, US Results as above from a search form...
    5. CFFILE - Uploading multiple files
      I'm having a problem trying to upload several files. I am using the code below. Any assistnace will be appreciated. Thanks Norm <cfdirectory...
  3. #2

    Default Re: CFFILE output multiple rows from a query

    Try this!

    <cfset FileData = "">

    <cfloop query="Dirlist">
    <cfset FileData = FileData & Dirlist.Name>
    </cfloop>

    <cffile action="WRITE" file="#dir#\filenamet" output="#FileData#">
    Stressed_Simon Guest

  4. #3

    Default Re: CFFILE output multiple rows from a query

    Using this code resulted in only the last record being written to the file.

    Anything else?
    robstacey Guest

  5. #4

    Default Re: CFFILE output multiple rows from a query

    OK VERY weird?????? Have you tried outputting the variable before the cffile to see if it has added all the data. Also cfdump the query to make sure it has what you think it does in it!
    Stressed_Simon Guest

  6. #5

    Default Re: CFFILE output multiple rows from a query

    try adding a carriage return to the loop stressed_simon suggested:



    <cfloop query="Dirlist">
    <cfset FileData = FileData & Dirlist.Name & Chr(13)>
    </cfloop>
    efecto747 Guest

  7. #6

    Default Re: CFFILE output multiple rows from a query

    Thank to everyone for your help. The resolution was:

    <cfset FileData = "">
    <cfloop query="query">
    <cfset FileData = FileData & query.var & #Chr(13)#&#Chr(10)#>
    </cfloop>

    <cffile action="WRITE" file="dir\filename" output="#FileData#">

    robstacey Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139