
ColdFusion MX 7 Getting Started Experience Tutorial Page 36 of 47
Learning Point: cfoutput tag placement
The placement of the cfoutput tags is significant. As you can see from the browser’s view source, this tag loops over
HTML tags as well as ColdFusion tags and variables to produce the final HTML code. In other words, everything between
the <cfoutput> and </cfoutput> tags is looped.
17. Leaving all of the output in one table cell makes it difficult to manage the spacing and display of the content. Move the
<cfoutput> and </cfoutput> tags so that they sandwich the table row tr tags, as the following code shows:
<table border="0" cellpadding="15" cellspacing="0" /jointfilesconvert/293559/bgcolor="#FFFFFF">
<cfoutput query="artwork">
<tr>
<td valign="top" align="center" width="200">
<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>
</td>
</tr>
</cfoutput>
</table>
18. Save and browse the page, and then view the page source.
Figure 54. The cfoutput
loops around the table row,
repeating all the HTML while
inserting the data from the
database
The display does not look very different, although you can see additional spacing between the text and the image that
follows it. Viewing the source gives more insight into what has happened. You can see that now each artwork block is
enclosed within individual cells, which are in turn enclosed within individual rows as the placement of the cfoutput tags
would suggest.
Kommentare zu diesen Handbüchern