Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 983

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Example
<!--- Create a query to extract artwork and associated information from the cfartgallery
database. --->
<cfquery name="artwork" datasource="cfartgallery">
SELECT FIRSTNAME, LASTNAME, ARTNAME, DESCRIPTION, PRICE, LARGEIMAGE, ISSOLD, MEDIATYPE
FROM ARTISTS, ART, MEDIA
WHERE ARTISTS.ARTISTID = ART.ARTISTID
AND ART.MEDIAID = MEDIA.MEDIAID
ORDER BY ARTNAME
</cfquery>
<cfset xctr = 1>
<table border="0" cellpadding="15" cellspacing="0" bgcolor="#FFFFFF">
<cfoutput query="artwork">
<cfif xctr mod 3 eq 1>
<tr>
</cfif>
<!--- Use the IsImageFile function to verify that the image files extracted
from thedatabase are valid. Use the ImageNew function to create a
ColdFusion image fromvalid image files. --->
<cfif IsImageFile("../cfdocs/images/artgallery/#artwork.largeImage#")>
<cfset myImage=ImageNew("../cfdocs/images/artgallery/#artwork.largeImage#")>
<td valign="top" align="center" width="200">
<cfset xctr = xctr + 1>
<!--- For artwork that has been sold, display the text string "SOLD!"
in white on the image. --->
<cfif artwork.isSold>
<!--- Resize myImage to fit in a 110-pixel square, scaled proportionately. --->
<cfset ImageScaleToFit(myImage,110,"","bicubic")>
<!--- Add a 5-pixel black border around the images. (Black is the default color. --->
<!--- Add a 5-pixel black border to myImage. --->
<cfset ImageAddBorder(myImage,"5")>
<!--- Write the images directly to the browser without saving them to the hard drive.
--->
<cfimage source="#myImage#" action="writeToBrowser"><br>
<strong>#artwork.artName#</strong><br>
Artist: #artwork.firstName# #artwork.lastName#<br>
Price: #dollarFormat(artwork.price)#<br>
#artwork.mediaType# - #artwork.description#<br>
</td>
</cfif>
<cfif xctr-1 mod 3 eq 0>
</tr>
</cfif>
</cfoutput>
</table>
<cfset ImageSetDrawingColor(myImage,"white")>
<cfset attr=StructNew()>
<cfset attr.size=45>
<cfset attr.style="bold">
<cfset ImageDrawText(myImage,"SOLD!",35,195, attr)>
</cfif>
Last updated 1/20/2012
978

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents