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.
Note: If you have only one search condition, you can use the simple Recordset dialog box to define
your recordset (see
To search for records in a database using SQL:
Open the results page in Dreamweaver, and then create a new recordset by opening the
1
Bindings panel (Window > Bindings), clicking the Plus (+) button, and selecting Recordset
from the pop-up menu.
Make sure the advanced Recordset dialog box appears.
2
If the simple dialog box appears instead, switch to the advanced dialog box by clicking the
Advanced button.
Enter a name for the recordset and select a connection.
3
The connection should be to a database containing data you want the user to search.
Enter a Select statement in the SQL text area.
4
Make sure the statement includes a WHERE clause with variables to hold the search
parameters. In the following example, the variables are called
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
writing SQL" on page
For help on SQL syntax, see
Give the SQL variables the values of the search parameters by clicking the Plus (+) button in the
5
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
contains one text field called "LastName" and another called "Department".
In ColdFusion, the runtime values would be
runtime values would be
request.getParameter("Department")
644
Chapter 40: Building ColdFusion Applications Rapidly
"Searching with only one search parameter" on page
532.
Appendix B, "SQL Primer," on page
request.getParameter("LastName")
varLastName
"Creating an advanced recordset by
and
#LastName#
#Department#
.
642).
and
varDept
753.
method and
GET
. In JSP, the
and
:
Need help?
Do you have a question about the DREAMWEAVER MX 2004-USING DREAMWEAVER and is the answer not in the manual?
Questions and answers