Displaying Search Results


Once you've defined a recordset for the results pages, you can add a dynamic table to display the search results. By including form objects on the search page in which the user can enter any value, such as the Price text field in the search_advanced.cfm page, you can use two Show Region server behaviors (Show If Recordset Is Not Empty and Show If Recordset Is Empty). The first behavior will display the dynamic table only if the recordset contains records, and the latter behavior will display a message if the user enters a value that's less than the values in the price field in the trips table.

In the first task in this section, you'll add a dynamic table to the results_simple.asp page to display the results using the search parameter submitted on the search_simple.asp page.

In the second task, you'll add a dynamic table, a Show If Recordset Is Not Empty server behavior to display the recordset results using the search parameters submitted from the search_advanced.cfm page, and a Show If Recordset Is Empty server behavior to display a message if no records match the submitted search parameters.

To add a dynamic table to display simple search results:

1.

Open results_simple.asp.

2.

Choose Insert > Application Objects > Dynamic Data > Dynamic Table to insert a dynamic table. The Dynamic Table dialog appears.

3.

From the Recordset drop-down list, choose the locations recordset (Figure 11.23).

Figure 11.23. Select the locations recordset in the Dynamic Table dialog.


4.

In the Show section, select the Records at a Time radio button. The default setting is 10.

The Repeat Region server behavior that's included in the Dynamic Table application object dynamically adds a row for every record in the recordset, up to the number of rows that you set in the Show field. If more rows are needed to display all the records, an additional page is created and recordset navigation links are automatically added.

5.

In the Border, Cell Padding, and Cell Spacing fields, enter values for the number of pixels for the width of the table border, the padding between the outer border of a cell and its contents, and the space between the cells. You can also use the supplied default values (Figure 11.23).

Tip

  • You may want to edit the names of the column headings to make the table easier for your page visitors to use. You can delete any columns you don't want to include, and change any design features of the table, such as background color, size, or border type.

6.

Click OK to close the dialog and insert the table.

The Dynamic Table application object inserts HTML table code, adds column headings to the first row of table cells using the recordset field names, adds placeholders for the recordset fields to the second row of table cells, and adds a Repeat Region server behavior to display multiple records in the table.

The table now appears in the Design view window. Figure 11.24 shows the first three columns of the table (Location, City, State or Country), but there are a total of five columns. The other two columns are Telephone and Fax.

Figure 11.24. The dynamic table includes column headers and placeholders for dynamic text. The first three columns of the table are shown.


7.

Save the page.

8.

Open the search_simple.asp page. Choose File > Preview in Browser.

9.

Make a selection from the menu and click the Submit button.

10.

View the results in the results_simple.asp page. All five table columns are shown in Figure 11.25.

Figure 11.25. The results page displays cafetownsend locations in Africa when Africa is selected from the menu on the search page.


To add a dynamic table to display advanced search results:

1.

Open results_advanced.cfm.

2.

Follow Steps 2 through 6 in the previous task to add a dynamic table using the eventTrips recordset and display the results from the search parameters submitted on the search_advanced.cfm page.

3.

In Design view, select the table.

4.

In the Application panel group, click the Server Behaviors tab to access the Server Behaviors panel.

5.

Click the plus button and select Show Region > Show If Recordset Is Not Empty from the menu (Figure 11.26).

Figure 11.26. Select the Show If Recordset Is Not Empty server behavior from the Server Behaviors menu.


The table will display the recordset results if the recordset contains records.

6.

Type a message on the page to display if the user entered an invalid value for the Price field on the search_advanced.cfm page (Figure 11.27).

Figure 11.27. A no-results message displays if the user enters an invalid value in the price text field on the search page.


7.

Select the message text that you typed in Step 6. On the Server Behaviors panel, click the plus button and select Show Region > Show If Recordset Is Empty from the menu.

This message will display if the recordset does not contain any records. The table will not display in this case.

8.

Save the page. Open search_advanced.cfm and choose File > Preview in Browser.

9.

Select an event from the menu, and enter a number from 1000 to 6000 in the price field. Click the Submit button to view the search results (Figure 11.28). Use the browser Back button to return to the search_advanced.cfm page, and enter 100 in the price field. Your message displays in the browser window (Figure 11.27).

Figure 11.28. The results page displays results for mountain biking trips with a price of $2000 or less.


Tip

  • You can make the results page a master page, and include links to additional information on a detail page. For more information on creating master/detail page sets, see Chapter 10.





Macromedia Dreamweaver 8 Advanced for Windows and Macintosh. Visual Quickpro Guide
Macromedia Dreamweaver 8 Advanced for Windows and Macintosh: Visual QuickPro Guide
ISBN: 0321384024
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Lucinda Dykes

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net