Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

probably simple cfoutput problem

Status
Not open for further replies.

pixiesfb

Programmer
Apr 27, 2001
62
US
I set firstname and lastname. The first set of output tags gives me two sets of names, which is correct. The second set output tags only gives me one name. Why?


<cfquery name=&quot;GetInfo&quot; datasource=&quot;datasrc&quot;>
Select firstname, lastname
from prjoff_us
where (id in (8, 9))
</cfquery>

<cfoutput query=&quot;getInfo&quot;>
<cfset xfirstname= Trim(firstname)>
<cfset xlastname= Trim(lastname)>

#xfirstname# #xlastname#
</cfoutput>

<cfoutput>
#xfirstname# #xlastname#
</cfoutput>
 
This is because your first <cfoutput> has the attribute query=&quot;getInfo&quot;. If the query attribute is included, then everthing between the <cfoutput></cfoutput> tags is executed for each entry returned from the query. Your query &quot;getInfo&quot; must have returned two entries.

I am not very good at explaining things, but I hope this helps.
 
I think randall2nd did a great job of explaining.

The reason you only get one set of names when you use just the <cfoutput> tag is because you aren't looping through a query. It's just outputting the last known values for #xfirstname# and #xlastname#. (Should be the second set of names from your <cfoutput query> tag.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top