ColdFusion 4.0 Primer

You'll notice I only had to include one table row between the CFOUTPUT tags, this is because ColdFusion will duplicate whatever is in the CFOUTPUT tags once for every row returned by the query, for your programmers out there CFOUTPUT behaves like a while loop.

Finally notice what is in the More Info column. This is a link to another page that also passes the FriendID as an argument. Lets take a look at that page now.

Figure 9. info.cfm
<CFQUERY DATASOURCE = "Friends" NAME = "INFO"> 
SELECT * 
FROM Friends 
WHERE FriendID = '#ID#' 
</CFQUERY> 


<div align = "center"> 
<CFOUTPUT QUERY = "INFO"> 
<h1>Friend Info For #FirstName# #LastName#</h1> 
<P> 
<b>Sex: #sex#</b><br> 
<b>Age: #age#</b><br> 
<b>Favorite Movie: #FavMovie#</b><br> 
<b>Favorite Color: #FavColor#</b><br> 
<b>Car: #car#</b><br> 
Comments:<br>
#ParagraphFormat(Comments)# 
</cfoutput> 
</div>

Now lets examine the above. In the Select statement I use an * because I want to select all of the fields. Then in the where statement I am using the ID variable I passed in the URL. This time for the output I do not put it in a table since each ID is unique and I know only one row will be returned. Then I list the variables as before with one exception. For the comment variable I include the ParagraphFormat function. What this function does is recognize the 2 blank lines between paragraphs and inserts a <p> tag there so that it is displayed correctly on the page.