Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:42:08+00:00 2026-05-27T14:42:08+00:00

I’ve gotten an error saying I cannot nest cfoutput tags when the tags use

  • 0

I’ve gotten an error saying I cannot nest cfoutput tags when the tags use the attribute “query”. I presume this is hinting at me combining the queries these two cfoutput tags are outputting.

The problem is, the MySQL query the first cfoutput tag is outputting the data from is printing out single pieces of information into a table, the “child” cfoutput tag is using a query that gets several pieces of information. So I don’t know how I’d do this.

Here’s the query that the “parent” cfoutput tag is outputting:

            SELECT DISTINCT s.id            AS  id,
                s.heading           AS  heading,
                s.reasonForSale     AS  reason,
                s.viewing           AS  viewing,
                s.additionalInfo    AS  additional,
                s.contents          AS  content,
                a.id                        AS  auctioneer_id,
                a.name                      AS  auctioneer,
                a.website                   AS  website,
                d.startDate                 AS  start_date,
                d.endDate                   AS  end_date,
                d.startTimeHours            AS  start_hour,
                d.startTimeMins             AS  start_min,
                d.startTimeType             AS  start_time_type,
                d.endTimeHours              AS  end_hour,
                d.endTimeMins               AS  end_min,
                d.endTimeType               AS  end_time_type,
                l.address                   AS  address,
                l.city                      AS  city,
                l.county                    AS  county,
                l.postcode                  AS  postcode,
                t.entryCopy                 AS  sale_type,
                f.filename                  AS  logo_file,
                s.featuredAuction           AS  featured,
                s.sale_of_week              AS  sow,
                s.brochure,
                s.auctioneerslink
        FROM    sales s,
                auctioneers a LEFT JOIN files f ON f.id = a.logoFile,
                saledates d,
                saleloc l,
                lookupcopy t
        WHERE   a.id                    =   s.auctioneer    AND
                d.saleId            =   s.id            AND
                t.id                =   s.saleType      AND
                l.id                =   d.saleLoc       AND
                d.id                =   #tmp_id#
        GROUP BY    id

Here is my new query, this will get several pieces of information, a list of things, I need to loop through when printing them. They’re image file names and will need wrapping in image tags, etc…

        SELECT      file_name
    FROM        sales_photos
    WHERE       sale_id = #tmp_id#
    ORDER BY    id

If I can’t nest these two cfoutput tags, how can I do this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:42:09+00:00Added an answer on May 27, 2026 at 2:42 pm

    ColdFusion is correct; you are unable to embed one cfoutput with a query attribute within another cfoutput (with a query attribute).

    You can, however, start a query output, and then within it…embed a new query, and loop over those results (which is already within the context of an cfoutput)–so long as you take care to scope the query name and columns (and which row) you are accessing–a la array indexing syntax rules.

    For this answer, assume that your 1st query (the giant one) is wrapped in a cfquery named “parent”:

    <cfoutput query="parent">
       <cfset file_name_qry = getFileNameFromID(parent.id[parent.currentrow]) />
       #parent.heading[parent.currentrow]#
         <cfloop from="1" to="#file_name_qry.recordcount#" index="i">
         #file_name_qry.file_name[i]#<br/>
         </cfloop>
    </cfoutput>
    
    <cffunction name="getFileNameFromID" returntype="query">
      <cfargument name="id" type="string" />
    
      <cfset var tmpQry = '' />
      <cfquery name="tmpQry" datasource="mydsn">
        SELECT      file_name
        FROM        sales_photos
        WHERE       sale_id = #arguments.id#
        ORDER BY    id
      </cfquery>
    
      <cfreturn tmpQry />
    </cffunction>
    

    Note the references to the names of the queries in the output.

    Note also that I wrapped the 2nd query in function for convenience; you don’t need to do this necessarily–you are free to inject the cfquery within the cfoutput.

    Of course, the real answer is to re-write your SQL query so that it joins to the necessary file_name attributes, and then you use a query with a group attribute…but I’ll leave that out of this answer as it is more complex, and requires knowledge of more advanced SQL as well as how the group attribute works.

    This answer will work for you, but the ColdFusion community will most likely spank you for looping within a loop–for now, it’ll solve your problem, and you can investigate the group attribute and a more advanced SQL statement later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.