
ColdFusion MX 7 Getting Started Experience Tutorial Page 33 of 47
Learning Point: Deconstructing the query variable syntax
Keep in mind the following rules regarding correct query variable syntax:
• Surround variables with number signs (#).
• Remove all spaces.
• Prefix the variable name by using the cfquery tag’s name attribute value (in this case, artwork).
• Follow the prefix with a period.
• Follow the period with the column name from the SELECT statement that you want to display.
Remember that ColdFusion is not case-sensitive, so while the column names are in all caps in the SELECT statement,
you write them here in mixed case. The case does not matter, but the coding methodology for this project uses mixed
case for ColdFusion variables. To see other methodology guidelines, see the Explore Real World Example Applications
section of the ColdFusion MX 7 Getting Started Experience.
10. Save the index.cfm page and browse it.
Figure 50. Variables don’t
get processed properly just
because you put number
signs (#) around them.
Again, ColdFusion treats the variables as text. This is because number signs alone do not signal a ColdFusion
variable, because they are often used in regular text that might appear on the page.
11. In order for ColdFusion to recognize that the number signs are variable indicators, you surround the section with
cfoutput tags, as the following code shows:
<table border="0" cellpadding="15" cellspacing="0" /jointfilesconvert/293559/bgcolor="#FFFFFF">
<tr>
<td valign="top" align="center" width="200">
<cfoutput>
<img src="images/#artwork.largeImage#" width="200" height="200"><br>
<strong>#artwork.artName#</strong><br>
Artist: #artwork.firstName# #artwork.lastName#<br>
Price: #artwork.price#<br>
#artwork.mediaType# - #artwork.description#<br>
<font color="#FF0000">#artwork.isSold#</font>
</cfoutput>
</td>
Kommentare zu diesen Handbüchern