Spooky's Databases > Querying the Database with a Search Form
One of the useful features of adding
database access to your web site, is that your viewers
can now customize a search form to locate the
information they want.
Adding a Database Search form
On a new or existing page, you
will insert a Database Results Wizard (DRW).
Open the Insert menu,
select Database, and click Results
Select the Use an existing
database connection button. Click on the
database name you wish to use. Each persons
database name will be different.
Click Next.
Make sure the Record source
option is selected and the table
you wish to query is selected from the list. Click
Next.
Select More Options.
In the More Options box,
click Criteria.
In the Criteria dialog
box, click Add.
In the Add Criteria
dialog box, click to select the Field Name
you wish to query from the list.
In the Comparison box,
select the type of query comparison. eg. If the field in your database is a text
field, and you want to provide 'LIKE' queries,
(where the field starts with, ends with, or
contains the phrase)
Select the 'Contains' option from the
Comparison list.
Normally you would use Equals (for numeric
fields) or Contains (for text fields) in
the Comparison list.
If you are going to use more than 1 query box on
your form, you may wish to select 'OR'
rather than the 'AND' option
eg.
AND : Selection = Box1 AND Selection = Box2 OR : Selection = Box1 OR Selection = Box2
Click OK.
Note : 'Use this search form field' allows you to
specify the name of the form you are passing to
the search page.
To add more criteria (search
boxes) repeat this process from 'G'
In the Criteria dialog
box, click OK.
When the page is first
displayed on the web, you can set a default
search by choosing a value to be used.
Notice, that now you have set a criteria, the
'Defaults' option is enabled.
Select 'Defaults'
Select Edit to add a
default value to the input parameters
Entering NULL will start an initial search with no
results.
Enter OK
In Step 3 of the DRW,
click Next.
Click Next in Step 4 of
the DRW, and click Finish in Step 5
On the File menu, click
Save As.
Make sure the page is saved as "file.asp"
and not "file.htm"