Is it possible to set a ColdFusion variable to a concatenated string?
<cfoutput query="getName">
<cfset myName=#Firstname# #Lastname#>
</cfoutput>
Doesn't seem to work, nor does
<cfoutput query="getName">
<cfset teacherName=#Firstname# + #Lastname#>
</cfoutput>
If you really need an additional variable, ColdFusion's concatenation operator is &
<cfset teacherName = Firstname &" "& Lastname>
Though for simple output, no extra variable is needed. Just output the column values:
<cfoutput query="getName">
#Firstname# #Lastname# <br>
</cfoutput>
As an alternative to using the ColdFusion &
or &=
string operators, you can also do the following:
<cfoutput query="getName">
<cfset myName="#Firstname# #Lastname#">
<p>#myName#</p>
</cfoutput>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With