Professional Web Applications Themes

Create text file from query - Coldfusion - Getting Started

I wantto create a simple text file from the requlsts of a query, but I can't seem to escape thequotes right. I am trying to run... <cfset ScrollerXML =" <cfoutput query='GetRates'> <country pkey="#CountryID#" scroller="#OnScroller#" rate="#CountryRate1#">#CountryName#</country>#chr(10)# </cfoutput> "> To give me a file that looks like: <country pkey="1" scroller="1" rate=".50">USA</country> <country pkey="2" scroller="0" rate=".75">GB</country> <country pkey="3" scroller="1" rate="1.50">USSR</country> how do I run that query insdie the <cfset> tag?...

  1. #1

    Default Create text file from query

    I wantto create a simple text file from the requlsts of a query, but I can't
    seem to escape thequotes right.

    I am trying to run...

    <cfset ScrollerXML ="
    <cfoutput query='GetRates'>
    <country pkey="#CountryID#" scroller="#OnScroller#"
    rate="#CountryRate1#">#CountryName#</country>#chr(10)#
    </cfoutput>
    ">

    To give me a file that looks like:

    <country pkey="1" scroller="1" rate=".50">USA</country>
    <country pkey="2" scroller="0" rate=".75">GB</country>
    <country pkey="3" scroller="1" rate="1.50">USSR</country>

    how do I run that query insdie the <cfset> tag?

    Efused Guest

  2. #2

    Default Re: Create text file from query

    try using CHR(34) instead fo the quotes in the actual output

    I also don't think running a loop inside a variable assignment will properly
    work.

    Try creating the variable and concatenating within the loop rather than the
    opposite.

    ... then when done save the final variable result to a file using CFFILE

    <cfset txtdata = "">

    <cfoutput query='GetRates'>
    <cfset txtdata="#txtdata#<country pkey=#CHR(34)##CountryID##CHR(34)#
    scroller=#CHR(34)##OnScroller##CHR(34)#
    rate=#CHR(34)##CountryRate1##CHR(34)#>#CountryName #</country>#chr(10)#">
    </cfoutput>

    SafariTECH Guest

Similar Threads

  1. Coldfusion to create a PDF file from a query
    By weiwei in forum Coldfusion Database Access
    Replies: 0
    Last Post: August 31st, 08:41 PM
  2. cfhttp query text file
    By bmyers in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: July 29th, 04:59 PM
  3. Create a table regarding a text file
    By Fredo in forum PHP Development
    Replies: 7
    Last Post: November 5th, 04:15 PM
  4. Create text file from CD-ROM projector
    By vij010 in forum Macromedia Director Basics
    Replies: 2
    Last Post: July 31st, 04:58 PM
  5. Cannot create a text file
    By Abhi in forum ASP.NET General
    Replies: 1
    Last Post: July 17th, 05:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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