Searching with only one search parameter

Searching with only one search parameter

If the search page submits a single search parameter to the server, then you can build the results page without SQL queries and variables. You create a basic recordset with a filter that excludes records that don’t meet the search parameter submitted by the search page.

To create the recordset to hold the search results:

  1. Open your results page in the Document window.

    If you don’t have a results page yet, create a blank dynamic page (File > New).

  2. Create a new recordset by opening the Bindings panel (Window > Bindings), clicking the Plus (+) button, and selecting Recordset from the pop-up menu.
  3. Make sure the simple Recordset dialog box appears.

    This is a picture of the feature being described.

    If the advanced dialog box appears instead, switch to the simple dialog box by clicking the Simple button.

  4. Enter a name for the recordset and select a connection.

    The connection should be to a database containing data you want the user to search.

  5. In the Table pop-up menu, select the table to be searched in the database.
  6. To include only some of the table’s columns in the recordset, click Selected and select the desired columns by Control-clicking (Windows) or Command-clicking (Macintosh) them in the list.

    You should include only the columns containing information you want to display on the results page.

Leave the Recordset dialog box open for now. You’ll use it next to retrieve the parameters sent by the search page and create a recordset filter to exclude records that don’t meet the parameters.

To create the recordset filter:

  1. From the first pop-up menu in the Filter area, select a column in the database table in which to search for a match.

    For example, if the value sent by the search page is a city name, select the column in your table that contains city names.

  2. From the pop-up menu beside the first menu, select the equal sign (it should be the default).
  3. From the third pop-up menu, select Form Variable if the form on your search page uses the POST method, or URL Parameter if it uses the GET method.

    The search page uses either a form variable or a URL parameter to pass information to the results page.

  4. In the fourth text box, enter the name of the form object that accepts the search parameter on the search page.

    The name of the object doubles as the name of the form variable or URL parameter. You can get the name by switching to the search page, clicking the form object on the form to select it, and checking the object’s name in the Property inspector.

    For example, suppose you want to create a recordset that includes only adventure trips to a specific country. Assume you have a column in the table called TRIPLOCATION. Also assume the HTML form on your search page uses the GET method and contains a menu object called Location that displays a list of countries. Here’s how your Filter section should look:

    This is a picture of the feature being described.

  5. If you want, click Test, enter a test value, and click OK to connect to the database and create an instance of the recordset.

    The test value simulates the value that would otherwise have been returned from the search page. Click OK to close the test recordset.

  6. If you’re satisfied with the recordset, click OK.

Dreamweaver inserts a server-side script on your page that, when run on the server, checks each record in the database table. If the specified field in a record meets the filtering condition, the record is included in a recordset. The script in effect builds a recordset containing only the search results.

The next step is to display the recordset on the results page. For more information, see Displaying the results.



Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly
Building ColdFusion Applications Rapidly
Reference
Building ASP.NET Applications Rapidly
Building ASP and JSP Applications Rapidly