Searching with multiple search parameters

Searching with multiple search parameters

If the search page submits more than one search parameter to the server, then you must write a SQL query for the results page and use the search parameters in SQL variables.

To search for records in a database using SQL:

  1. Open the results page in Dreamweaver, and then create a new recordset by opening the Bindings panel (Window > Bindings), clicking the Plus (+) button, and selecting Recordset from the pop-up menu.
  2. Make sure the advanced Recordset dialog box appears.

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

  3. 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.

  4. Enter a Select statement in the SQL text area.

    Make sure the statement includes a WHERE clause with variables to hold the search parameters. In the following example, the variables are called varLastName and varDept:

    SELECT EMPLOYEEID, FIRSTNAME, LASTNAME, DEPARTMENT, EXTENSION ?
    FROM EMPLOYEE WHERE LASTNAME LIKE 'varLastName' AND DEPARTMENT ?
    LIKE 'varDept'
    

    To reduce the amount of typing, you can use the tree of database items at the bottom of the advanced Recordset dialog box. For instructions, see Creating an advanced recordset by writing SQL.

    For help on SQL syntax, see SQL Primer.

  5. Give the SQL variables the values of the search parameters by clicking the Plus (+) button in the Variables area and entering the variable’s name, default value (the value the variable should take if no runtime value is returned), and runtime value (usually a server object holding a value sent by a browser, such as a request variable).

    In the following ASP example, the HTML form on the search page uses the GET method and contains one text field called "LastName" and another called "Department".

    This is a picture of the feature being described.

    In ColdFusion, the runtime values would be #LastName# and #Department#. In JSP, the runtime values would be request.getParameter("LastName") and request.getParameter("Department").

  6. If you want, click Test to create an instance of the recordset using the default variable values.

    The default values simulate the values that would otherwise have been returned from the search page. Click OK to close the test recordset.

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

    Dreamweaver inserts the SQL query in your page.

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