Welcome!

ColdFusion Authors: Maureen O'Gara, Hovhannes Avoyan, Yakov Fain, Pat Romanski, Liz McMillan

Related Topics: ColdFusion

ColdFusion: Article

Creating Database-Driven Websites Using ColdFusion MX 7 on Mac OS X

This is just the beginning

Step 5: Build Your First Dynamic Page
Your first dynamic page provides very basic functionality available in all application server languages - the dynamic page include. The following steps show you how to use the ColdFusion insert panel in Dreamweaver to insert a ColdFusion CFINCLUDE tag into your page:

  1. In Dreamweaver, select File > Open and browse to index.cfm in the coldfusiondemo folder, where you placed all your sample files.
  2. Within Design view, scroll to the bottom of the page and locate the empty area beneath the main left column. Click in the empty area.
  3. On the Insert panel, click the pop-up menu and select CFML to show the CFML-related buttons on this panel (see Figure 3), which you'll need to incorporate standard ColdFusion functionality into your Web page.
  4. Click the cfinclude button (see Figure 4). When you select this option, the Tag Editor dialog box appears and asks for the path for the included file.
  5. Browse to footer.html inside your coldfusiondemo folder.
  6. Click OK.
You've just created a simple call to include a snippet of HTML into your ColdFusion template. When you run index.html, ColdFusion will include the HTML in footer.html dynamically at runtime. Save your file and upload both index.cfm and footer.html to your testing server.

Step 6: Build Your First Database Query in a Dynamic Page
Now to build database access into your dynamic page. Over the next several steps, you'll use the Application panel in Dreamweaver to create a recordset that selects records from a database and places those records on the page:

  1. Open the Application panel in Dreamweaver if you haven't done so already. It displays a list of steps you must complete before you can do any dynamic development. Most likely, the first unchecked step is the RDS password step.
  2. Click the step to provide Dreamweaver with the RDS password to connect to your ColdFusion server. (You entered this password in Step 13 during the ColdFusion installation procedure earlier.)
  3. Click the Bindings tab in the Application panel. This is where you create your first recordset from the database.
  4. Click the plus (+) sign in the upper left corner of the panel and select Recordset (Query) from the pop-up menu.
  5. In the Recordset dialog box, name the recordset rsCoupons.
  6. For Datasource, select cfbookclub_pb.
  7. For Table, select BOOKCLUB.COUPONS.
  8. You want to sort the coupons by date, so in the Sort section select EXPIRATIONDATE and Descending in their respective pop-up menus.
  9. Click OK.
This query creates a recordset on the page that you can output using the Bindings tab in Dreamweaver. The Bindings tab displays the individual fields accessible from this recordset.

Follow these steps to output these fields on the page:

  1. Highlight the text "COUPON TEXT" on the right side of the index.cfm page in Design view.
  2. With that text highlighted, select the COUPON field from the list of fields in the Bindings tab in the Application panel.
  3. Click the Insert button at the bottom of the Bindings tab to insert the COUPON field onto your page. This places the dynamic field directly on the page.
  4. Highlight the text "Expiration Date" on the right side of the index.cfm page.
  5. Select the EXPIRATIONDATE field from the list of fields in the Bindings tab.
  6. Click Insert to add the dynamic field to the page.
  7. With that field still selected on the page, format the data by selecting the Format column pop-up menu in the Bindings panel.
  8. Format the field as a date using whichever mask you prefer (see Figure 5).
Finally, to output more than one record from this recordset, add a repeating region to the page:
  1. Highlight the two new dynamic fields you just added to your page.
  2. From the Server Behaviors tab in the Application panel, click the plus (+) sign and add a Repeat Region to the page.
  3. A dialog box appears and asks you to specify how many records to display. Type 2 to show two records at a time.
  4. Click OK.
Step 7: Test Your Page
Time to test your page:
  1. Save all changes you have made to your page.
  2. Upload all your files from the Dreamweaver site to your Web server.
  3. View the following URL in your browser: http://localhost:8500/ColdFusionDemo/index.cfm
This page displays the included footer file and the dynamic data from the query output in the sidebar.

Congratulations! You've just created your first database-driven page using ColdFusion on a Mac.

Where to Go from Here
As you can see, developing and testing ColdFusion applications on a Mac is easy. ColdFusion is a robust application server; what you've accomplished is just the beginning.

With a little digging around in the Application panel in Dreamweaver, you can explore all that is possible in a point-and-click environment until you become more comfortable with the ColdFusion language. The functionality ranges from user authentication to inserting and updating data in a database, all through a Web page that requires little-to-no hand coding. What a great way to learn a language!

If you are an existing Dreamweaver user, jump in and try ColdFusion and learn how easy it can be to create database-driven, dynamic Websites. Start out by visiting the Getting Started page (www.macromedia.com/devnet/coldfusion/getting_started.html) in the ColdFusion Developer Center, and then see where your creativity takes you.

More Stories By David Stutler

David Stutler is the owner and operator of WideEyed Media (www.wideeyedmedia.net), a new media development group located in Kansas City. In addition to his production duties, David serves as the lead Flash and Dreamweaver instructor for ThinqDigital, a Macromedia Authorized Training Partner. David is also an avid musician, spending the last 11 years in the vocal group measureXmeasure.

Comments (6) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Michael Long 04/26/06 07:02:34 PM EDT

Just a rehash. I was hoping that the article would tell me how to get CF MX running on the latest generation of Intel Macs, but such was not to be. So note: If you have a new Intel-based Mini, iMac, or MacBook Pro, these instructions will NOT work.

SYS-CON Italy News Desk 04/18/06 04:34:26 PM EDT

It's not every day that you get the opportunity to pen an article about true love and technology. But in a few cases, true love and technology mix quite well.

SYS-CON Brasil News Desk 04/18/06 12:15:09 PM EDT

It's not every day that you get the opportunity to pen an article about true love and technology. But in a few cases, true love and technology mix quite well.

SYS-CON Brasil News Desk 04/17/06 04:10:51 PM EDT

It's not every day that you get the opportunity to pen an article about true love and technology. But in a few cases, true love and technology mix quite well.

SYS-CON India News Desk 04/17/06 12:33:14 PM EDT

It's not every day that you get the opportunity to pen an article about true love and technology. But in a few cases, true love and technology mix quite well.

SYS-CON Australia News Desk 04/17/06 11:35:16 AM EDT

It's not every day that you get the opportunity to pen an article about true love and technology. But in a few cases, true love and technology mix quite well.