
ColdFusion MX 7 Getting Started Experience Tutorial Page 32 of 47
7. Since you have verified that the data is being retrieved from the database, you no longer need the cfdump tag.
However, rather than remove it (since you might need it again), you can just use a ColdFusion comment to comment
it out of the page, as the following figure shows. Doing so tells ColdFusion to ignore that command.
<cfquery name="artwork" datasource="cftutorial">
SELECT FIRSTNAME, LASTNAME, ARTNAME, DESCRIPTION, PRICE, LARGEIMAGE, ISSOLD, MEDIATYPE
FROM ARTISTS, ART, MEDIA
WHERE ARTISTS.ARTISTID = ART.ARTISTID
AND ART.MEDIAID = MEDIA.MEDIAID
</cfquery>
<!--- <cfdump var="#artwork#"> --->
Learning Point: CFML comments
HTML comments have only two dashes on each side of the comment; CFML comments have three dashes.
<!-- this is an HTML comment -->
<!--- this is a CFML comment --->
However, the difference between an HTML and a CFML comment is profound. CFML comments, like other ColdFusion
tags and variables, are stripped out of the page. Therefore, you can use CFML comments liberally without worrying about
them showing up in the browser’s view source.
8. You need to display the database data in the table. To start, remove all of the rows except for one and all of the cells
in that one row except for one, as the following code shows:
<table border="0" cellpadding="15" cellspacing="0" /jointfilesconvert/293559/bgcolor="#FFFFFF">
<tr>
<td valign="top" align="center" width="200">
<img src="images/austin01.jpg" width="200" height="200"><br>
<strong>1958</strong><br>
Artist: Austin Weber<br>
Price: $75,000.00<br>
Painting - Charcoal<br>
<font color="#FF0000">Sold!</font>
</td>
</tr>
</table>
You will use CFML to generate all of the rows and cells that you need.
9. Replace the image filename, artwork name, artist’s name, price, media type, description, and sold status with the data
that was retrieved in the artwork variable. Do this by referencing the variables and surrounding them with number
signs, as the following figure shows:
<table border="0" cellpadding="15" cellspacing="0" /jointfilesconvert/293559/bgcolor="#FFFFFF">
<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>
</table>
Commenti su questo manuale