The user interface has been simplified in Dreamweaver CC and later. As a result, you may not find some of the options described in this article in Dreamweaver CC and later. For more information, see this article.
You can use Dreamweaver to build a set of pages to let users search your database and view the search results.
In most cases, you need at least two pages to add this feature to your web application. The first page is a page that contains an HTML form in which users enter search parameters. Although this page doesn’t do any actual searching, it is referred to as the search page.
The second page you need is the results page, which performs most of the work. The result’s page does the following tasks:
Reads the search parameters submitted by the search page
Connects to the database and searches for records
Builds a recordset with the records found
Displays the contents of the recordset
Optionally, you can add a detail page. A detail page gives users more information about a particular record on the results page.
If you have only one search parameter, Dreamweaver lets you add search capabilities to your web application without using SQL queries and variables. Simply design your pages and complete a few dialog boxes. If you have more than one search parameter, you need to write a SQL statement and define multiple variables for it.
Dreamweaver inserts the SQL query in your page. When the page runs on the server, each record in the database table is checked. If the specified field in a record meets your SQL query conditions, the record is included in a recordset. The SQL query in effect builds a recordset containing only the search results.
For example, field sales staff might have information about customers in a certain area who have incomes above a certain level. In a form on a search page, the sales associate enters a geographical area and a minimum income level, and then clicks the Submit button to send the two values to a server. On the server, the values are passed to the results page’s SQL statement, which then creates a recordset containing only customers in the specified area with incomes above the specified level.
A search page on the web typically contains form fields in which the user enters search parameters. At minimum, your search page must have an HTML form with a Submit button.
To add an HTML form to a search page, complete the following procedure.
When the user clicks the form’s Search button, the search parameters are sent to a results page on the server. The results page on the server, not the search page on the browser, is responsible for retrieving records from the database. If the search page submits a single search parameter to the server, 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.
If you have more than one search condition, you must use the advanced Recordset dialog box to define your recordset (see Build an advanced results page ).
In the fourth 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. The following example shows how your Filter section should look:
A server-side script is inserted on your page that checks each record in the database table when it runs on the server. If the specified field in a record meets the filtering condition, the record is included in a recordset. The script builds a recordset that contains only the search results.
The next step is to display the recordset on the results page. For more information, see Display the search results .
If the search page submits more than one search parameter to the server, you must write a SQL query for the results page and use the search parameters in SQL variables.
If you have only one search condition, you can use the simple Recordset dialog box to define your recordset (see Build a basic results page ).
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'
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 run-time value is returned), and run-time 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:
After creating a recordset to hold the search results, you must display the information on the results page. Displaying the records can be a simple matter of dragging individual columns from the Bindings panel to the results page. You can add navigation links to move forward and backward through the recordset, or you can create a repeating region to display more than one record on the page. You can also add links to a detail page.
For more information on methods of displaying dynamic content on a page other than displaying results in a dynamic table, see Displaying database records.
Your set of search and results pages can include a detail page to display more information about specific records on the results page. In this situation, your results page also doubles as the master page in a master-detail page set.
You can create a link that opens a related page and that passes existing parameters to that page. The server behavior is only available when using the ASP server model.
Before adding a Go To Related Page server behavior to a page, make sure the page receives form or URL parameters from another page. The job of the server behavior is to pass these parameters to a third page. For example, you can pass search parameters received by a results page to another page and save the user from entering the search parameters again.
Also, you can select text or an image on the page to serve as the link to the related page, or you can position your pointer on the page without selecting anything, and the link text is inserted.