Lesson 15. Building Update Pages

In this lesson, you will build an interface that lets employees change a registered user from one user group to another (from visitor to admin, or vice versa). This implies a certain workflow: To add an employee to the admin group, the employee must first register at the site, and then another employee must go in and change her or his user group. Likewise, if an employee leaves Newland Tours, another employee can easily change the user profile back to visitor. The interface will use two pagesone where the employee selects the user whose profile will be changed, and one to actually update the profile.

Two-page applications that use this structure are referred to as master-detail page sets. A master-detail page structure is one of the most commonand usefulstructures that you will master as a Web developer. The first page is the master page, because it lists many records in a summary format. Users browse this summary, and then select the record they want to learn more about or modify/delete. The second page is the detail page, because it contains detailed information about the selected record. On this page, users can learn more about a product or modify/delete a record.

You'll enable users to update database data using a Web form, SQL's UPDATE statement, and Dreamweaver's Update Record server behavior.

graphics/15fig01.gif

To summarize, the master page lists a small sampling of fields from multiple records within a database, while the detail page displays many fields from a single record.

You've already built two master-detail page sets in the course of the book: The country profile pages perfectly fit this description, and the tour description page set is a variation on the theme. But in both cases, the detail page only displayed data. In this lesson, you'll use the detail page to update data.

Updating data is slightly more complex than inserting new data, which you did in Lessons 13 and 14. When you insert new data, you identify a table and specify which data to write to which fields in that table. When updating data, you have to do the same thing to a particular, existing record; you can't just append information as a new record at the end of the table. SQL has a commandUPDATEthat you can use to accomplish this task, and Dreamweaver has an Update Record server behavior that makes it even easier.

In this lesson, you will combine the master-detail page structure with the update-record page structure. You will use several Dreamweaver behaviors to make it happen. It is vital in this lesson that you understand the big picture about what is happening: Dreamweaver behaviors sometimes make it easy for us to not worry too much about the mechanics of what's going on, but in the next lesson, you are going to replicate this structure using a more ambitious hands-on approach, so it's best now if you nail down the concepts.

WHAT YOU WILL LEARN

In this lesson, you will:

  • Plan for a master-detail set, by analyzing the data needed for the application

  • Create a master-detail page set, using the admin template created in the previous lesson

  • Learn about SQL's UPDATE statement

  • Convert the detail page to a dynamically populated form capable of updating, rather than merely displaying, contents in the database

APPROXIMATE TIME

This lesson takes approximately one hour to complete.

LESSON FILES

Starting Files

Lesson15/Start/newland/admin_template.asp

Completed Files

Lesson15/Complete/newland/admin_addUser_master.asp

Lesson15/Complete/newland/admin_addUser_detail.asp