Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default cfoutput and cfloop

    Hi all, well this is my question:

    I want to show 2 or more different sets of record sets but one or more of them
    have to be nested on the first, since I cant do

    <cfoutput query="query1">
    <cfoutput query="query2"> </cfoutput>
    </cfoutput>

    I tried replacing the second cfoutput with cfloop

    <cfoutput query="query1">
    <cfloop query="query2"> </cfloop>
    </cfoutput>

    Now this works fine for outputting the data in the second query but for some
    reason the data in the first nested inside the second query wont update
    (example)

    <cfoutput query="query1">
    <cfoutput query="query2">
    #query1.id# #query2.name#
    </cfoutput>
    </cfoutput>

    I will always get the first query id in that output and not the "current"
    one.. why is this happening?? hope I made myself clear hehe seems like a lot of
    examples

    raulriera Guest

  2. Similar Questions and Discussions

    1. Cfoutput help!!!
      I am trying to figure out how to output records from a query that is returing 2 distinct table rows from each query. THe out put needs to look like...
    2. cfoutput and css
      I declare an entire document within a <cfoutput> </cfoutput> section. I am trying to insert the following css style descriptor into the code: ...
    3. Listbox, CFOUTPUT, and CFLOOP
      I'm trying to create a form to update a record. This record is already saved in the DB of course, so all the fields already have values. I'm able to...
    4. concat cfloop index to cfoutput variable inside loop?
      Hi, STUPID question here: I have a cfloop, index j. I have a text field, DESCRIPTION_#j#, inside the loop. I want to populate the VALUE of the...
    5. <cfoutput>
      Hi. I'm trying to rename a file but I get an error message. My code looks someting like this: <cfset source='C:\MyDocs\old.doc'> <cfset...
  3. #2

    Default Re: cfoutput and cfloop

    When looping through 2 queries, the outer query seems to be lost (for the
    values of that row)

    <cfoutput query="query1">
    <cfset query1ID = query1.id>
    <cfloop query="query2">
    #query1ID# #query2.name#
    </cfloop>
    </cfoutput>

    This should do it.

    Ken


    The ScareCrow Guest

  4. #3

    Default Re: cfoutput and cfloop

    Hi

    I think it is having some problem(bug).
    even i faced similar problem.

    See this code :

    <cfquery name="parttype" datasource="party">
    select * from parttype
    </cfquery>
    <cfoutput query="parttype">
    <cfquery name="parts" datasource="party">
    select * from parts where partTypeID=#parttype.partTypeID#
    </cfquery>
    <cfloop query="parts">
    #parttype.parttype#&nbsp;&nbsp;#name#
    </cfloop>
    #parttype.partTypeID#,#parttype#<br>
    </cfoutput>

    in the cfloop when i display #parttype.parttype# i am getting it as 1 only.
    means the first id.
    but after the cfloop i will get the correct #parttype.parttype# value.


    vkunirs Guest

  5. #4

    Default Re: cfoutput and cfloop

    Hi Ken

    that way we can do easily but we need store that field value into another varaible and we need to use that variable in the loop
    that is i am doing till now.

    k any how many thanks.
    vkunirs Guest

  6. #5

    Default Re: cfoutput and cfloop

    Thank you all guys, I guess it is a bug since its something so simple :S storing the data in a variable worked fine.

    Thanks again
    raulriera 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