|
Categories
|
|
|
|
|
|
ColdFusion Tutorial - More CFOUTPUT
|
|
Published
05/19/2006
|
Macromedia ColdFusion MX
|
|
|
|
|
|
Page 4 — More CFOUTPUT This little ditty is the key that makes you the Big Cheese in the eyes of your boss/client, because it controls the way your selected records are output in HTML. All you need is a <CFOUTPUT>tag and the name of a query you defined in your top statement: <CFOUTPUT QUERY="pocket"> Once you've defined that, you're free to go hog wild with your variables. You have all HTML tags at your command as well, but remember that anything put within <CFOUTPUT>tags is going to repeat again and again down your page until all your selected records have been accounted for. For example, you wouldn't want to use this code.... <CFOUTPUT QUERY="pocket"> Items in Pocket #item# </CFOUTPUT>
... because your output would look like this: Items in PocketOne Bouncy Ball with Psychedelic Markings Items in PocketHalf of a Cheese Sandwich Items in PocketA Bus Transfer etc.... You don't need that kind of trauma in your life right now. One header line is sufficient, so we should place it before the output tag, so it won't get repeated for each record, like this: Items in Pocket <CFOUTPUT QUERY="pocket"> #item# </CFOUTPUT> That way we'll get: Items in PocketOne Bouncy Ball with Psychedelic Markings Half of a Cheese Sandwich A Bus Transfer etc.... You can do all sorts of HTML formatting on your variables and place them anywhere you'd like. Let's get a little fancier by bolding each item line and adding a label before each entry like this: <CFOUTPUT QUERY="pocket"> Item: #Item#
Acquired: #Acquired#
Value: #Value#
</CFOUTPUT> The output would then look like this for each item: Item: One Bouncy Ball with Psychedelic Markings Acquired: 12 December 1998 Value: 25 cents ColdFusion also has special built-in tags that will take your formatting even further. Come along and take a look.
|