Adobe dreamweaver cs5 classroom in a book(bbs)

Page 374

Building pages with ASP, ColdFusion, or PHP Note: Developing dynamic applications is an exacting chore that can fail for the simplest reasons. Read and follow every step in this lesson carefully.

In Lesson 14, “Working with Online Data,” you learned how to select a server model, set up a testing server, and connect to an online database. Once connected, Dreamweaver makes it easy to access this data to create dynamic content.

Creating a recordset The next step in the process of generating dynamic content is to create a recordset. A recordset is an array of information pulled from one or more tables in your database in response to a question posed by code in the web page written in Structured Query Language (SQL).

Warning: This exercise can only be completed if you have successfully configured a testing server and connected to the greendata database as you were instructed in Lesson 14, “Working with Online Data.” Note: If you were using the jumpstart method in Lesson 14, you may continue to use the same site setup, files, and folder for Lesson 15.

The question, or query, can be as simple as “Show me all the events in the Events table,” or as complex as “Show me the events in the table that occur after May 1st that cost less than $10 and list them in descending alphabetical order.” Frequently, the query is also dynamic—created by the user by clicking on checkboxes or radio buttons, choosing from menus, or typing into a text field (as you do on Google and Yahoo). Like ASP, ColdFusion, and PHP, SQL is a robust language with its own terms, structure, and syntax. Dreamweaver can help you write most of the statements you’ll ever need, but to perform complex data routines you may need to hire a professional or learn some SQL yourself. Adobe provides a good SQL primer at tinyurl.com/yk5xnag, or you can check out tinyurl.com/6l43z for the SQL tutorial offered by W3Schools. In this exercise, you’ll create the 2010 event calendar dynamically by using a table from your current database connection. 1 Open events.html from the site root folder. Examine the Databases panel.

Tip: If the database connection doesn’t appear, check the Databases panel to see what steps need to be completed before you can connect. In most cases, you will only have to click the link to select a document type, as described in Lesson 14.

354

LESSON 15

The database connection you created earlier is not visible and the plus icon is grayed out, indicating that you can’t create a database connection even if you wanted to. The Events page uses the extension .html, which is not compatible with any dynamic server model other than Ajax. 2 Select File > Save As. Change the name to events.php. For ASP you should use the extension .asp and for ColdFusion you should use the extension .cfm, or as appropriate for your server model. The database connection should appear in the Databases panel. Dreamweaver provides the database connection automatically (if you made one already) as soon as you open or save a page with a compatible extension.

Building Dynamic Pages with Data


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.