Categories

Partners
  • Website Templates

  • Design Feeds

  • Adobe Photoshop Tutorials

  • Website Templates, WordPress Themes

  • Website Templates

  • Flash Web Sites

  • Photoshop Templates

  • Photo Contests

  • Photo Tips
  • Search


    Advanced Search


    Partner Links
  • Adobe Photoshop Tutorials

  • Free Stock Photos and Images



  • Website Templates

    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 Pocket

    One Bouncy Ball with Psychedelic Markings

    Items in Pocket

    Half of a Cheese Sandwich

    Items in Pocket

    A 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 Pocket

    One 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.

    Article Series
    This article is part 5 of a 7 part series. Other articles in this series are shown below:
    1. ColdFusion Tutorial - Lesson 2
    2. ColdFusion Tutorial - ColdFusion Templates
    3. ColdFusion Tutorial - Template Basics
    4. ColdFusion Tutorial - SQL Statements
    5. ColdFusion Tutorial - More CFOUTPUT
    6. ColdFusion Tutorial - CFIF and CFELSE
    7. ColdFusion Tutorial - Review