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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do these examples need <cfoutput> or not? 2

Status
Not open for further replies.

leadman

Programmer
Jun 11, 2001
177
0
0
US
Im trying to understand when to use and not use <cfoutput>. Could someone please look at the following four examples (all of which use cfoutput) and tell me whether or not they need it:

=========EXAMPLE 1 &quot;dbfields&quot; is a local list==========

<cfquery name=&quot;checkbdup&quot; datasource=&quot;mydata&quot; maxrows=&quot;1&quot;>
SELECT max(bID) AS bill_id FROM billing
WHERE 0=0
<cfloop list=&quot;#dbfields#&quot; index=&quot;i&quot;>
<cfif len(evaluate(i))>
<cfoutput>
and #i# = '#evaluate(i)#'
</cfoutput>
</cfif>
</cfloop>
</cfquery>

============EXAMPLE 2 setting from query==========

<cfif checkbdup.bill_id is NOT &quot;&quot;>
<cfoutput query=&quot;checkbdup&quot;>
<cfset billingID = #checkbdup.bill_id#>
</cfoutput>
<cfelse>

=======EXAMPLE 3 (variables passed by form========

<cfquery datasource=&quot;mydata&quot;>
insert into billing
(firstname,lastname,phone,fax,email,address1,address2,city,state,zip)
VALUES
<cfoutput> ('#firstname#','#lastname#','#phone#','#fax#','#email#','#address1#','#address2#','#city#','#state#','#zip#')
</cfoutput>
</cfquery>

====EXAMPLE 4 (variables from 2 places passed to sql)====

<cfloop collection=&quot;#session.cart#&quot; item=&quot;i&quot;>
<cfquery name=&quot;qAddOrderItem&quot; datasource=&quot;mydata&quot;>
insert into order_items
frn_order_id,frn_product_id,quantity)
VALUES <cfoutput query=&quot;qGetOrderID&quot;>
(#qGetOrderID.order_ID#,
</cfoutput>
<cfoutput>'#session.cart[1]#',
#session.cart[4]#
</cfoutput>)
</cfquery>
</cfloop>
 
None of them need <CFOUTPUT>

=========EXAMPLE 1 &quot;dbfields&quot; is a local list==========

<cfquery name=&quot;checkbdup&quot; datasource=&quot;mydata&quot; maxrows=&quot;1&quot;>
SELECT max(bID) AS bill_id FROM billing
WHERE 0=0
<cfloop list=&quot;#dbfields#&quot; index=&quot;i&quot;>
<cfif len(evaluate(i))>
<cfoutput>
and #i# = '#evaluate(i)#'
</cfoutput>
</cfif>
</cfloop>
</cfquery>

============EXAMPLE 2 setting from query==========

<cfif checkbdup.bill_id is NOT &quot;&quot;>
<cfoutput query=&quot;checkbdup&quot;>
<cfloop query=&quot;checkbdup&quot;>
<cfset billingID = #checkbdup.bill_id#>
</cfloop>
</cfoutput>
<cfelse>

=======EXAMPLE 3 (variables passed by form========

<cfquery datasource=&quot;mydata&quot;>
insert into billing
(firstname,lastname,phone,fax,email,address1,address2,city,state,zip)
VALUES
<cfoutput> ('#firstname#','#lastname#','#phone#','#fax#','#email#','#address1#','#address2#','#city#','#state#','#zip#')
</cfoutput>
</cfquery>

====EXAMPLE 4 (variables from 2 places passed to sql)====

<cfloop collection=&quot;#session.cart#&quot; item=&quot;i&quot;>
<cfquery name=&quot;qAddOrderItem&quot; datasource=&quot;mydata&quot;>
insert into order_items
frn_order_id,frn_product_id,quantity)
VALUES <cfoutput query=&quot;qGetOrderID&quot;>
(#qGetOrderID.order_ID#,
</cfoutput>
<cfoutput>'#session.cart
Code:
[
1
Code:
]
#',
#session.cart
Code:
[
4
Code:
]
#
</cfoutput>)
</cfquery>
</cfloop> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top