Penn Computing
Computing Menu Computing A-Z
Computing Home Information Systems & Computing Penn

Simple Database Search - Creating a search form

Simple Database Search is a generic CGI search utility developed for web providers on the host www.upenn.edu. Simple Database Search will create a search form for your users to search a flat database file based on values that you've set in a specified configuration file.

If you prefer to have the script create a search form for you, see the main homepage for details on creating a link to Simple Database Search. If you prefer to create your own customized search form, there are certain values that you must include in your customized search form. Bolded text must be included in your search form exactly as shown.

form tag The <form> tag in your form should call the Simple Database Search script and should include the path to your configuration file, starting at the HTML root. The syntax is:

<form method=POST action="/cgi-bin/dbsearch.pl/[providerdir]/[configuration file]>
For example, if your provider directory is "http://www.upenn.edu/computing/jobs/" and your configuration file is located in that directory and called "searchdb.cfg", then your form tag should be:
<form method=POST action="/cgi-bin/dbsearch.pl/computing/jobs/searchdb.cfg">


action input tag You must include a hidden <input> tag that specifies that you want the script to just search the database rather than creating the default search form.

<input type="hidden" name="action" value="search">


searchstring input tag If you opt to allow your users to search for a string, you must include an <input> tag with a name of "searchstring".

<input type="text" name="searchstring" size=30>


searchfields select tag If you opt to allow your users to search for a string in a specific field, you must include a <select> tag with a name of "searchfields". You would then list each header name of the fields in your database as specified in your header record in the database file. You can use whatever text you want to describe the select list options. If you opt to allow your users to search all fields, that option must have a value of "0".

<select name="searchfields">
<option value=0 selected>Search all fields
<option value="SSN">Student's SSN
<option value="Ref Lastname">Recommender's Lastname
<option value="Ref Firstname">Recommender's Firstname
<option value="Ref Middleinit">Recommender's Middlename
<option value="Student Lastname">Student's Lastname
<option value="Student Firstname">Student's Firstname
<option value="Student Middleinit">Studen'ts Middlename
</select>

If you want to allow your users to choose multiple fields to search, your <select> tag should look like:

<select name="searchfields" multiple>


selectlists select tag If any particular field in the database can contain only one value from a finite list of possible values, the provider can opt to present those possible values to the user in a select list in the search form. See the Simple Database Search page for more information on setting up selectlists in your configuration file.

Once you've set up your selectlists, you would add those menus to your search form.

<select name="search_Job Description">
<option value=0>Choose job description
<option value="Programmer/Analyst">Programmer/Analyst
<option value="Database Administrator">Database Administrator
<option value="Systems Programmer">Systems Programmer
<option value="Systems Engineer">Systems Engineer
</select>
The "name" of each <select> tag would be the field header name preceeded by search_. If there are any spaces in the field header name, you need to make sure and include quotes around the header name in the select tag for that header. In our above example, the field header name is
Job Description
The <select> tag name would be
<select name="search_Job Description">.
The values for the <select>tag would be all of the possible values for the field as specified in the database configuration file.


view select tag The Simple Database Search script can show search results in two formats:
  • long view - paragraphs of text
    Job Description: Programmer/Analyst
    Department: ISC Networking
    Salary Level: B
  • quick view - tabled display
    Job Description Department Salary Level
    Programmer/Analyst ISC Networking B
If you wish to give your users the ability to choose between the two formats, you must include a <select> tag with a name of "view".
<select name="view">
<option value="long">Long View (Text only)
<option value="quick">Quick View (Table view)
</select>
If you don't wish to give your users the ability to choose between the two formats, the script will default to the quick view. If you'd rather show your search results in the long view, add an <input> tag like:
<input type="hidden" name="view" value="long">


displayfields select tag If you opt to allow your users to display only a selected field in the returned search results, you must include a <select> tag with a name of "displayfields". You would then list each header name of the fields in your database as specified in your header record in the database file. If you opt to allow your users to search all fields, that option must have a value of "0".

<select name="displayfields">
<option value=0 selected>Display all fields
<option value="SSN">Student's SSN
<option value="Ref Lastname">Recommender's Lastname
<option value="Ref Firstname">Recommender's Firstname
<option value="Ref Middleinit">Recommender's Middlename
<option value="Student Lastname">Student's Lastname
<option value="Student Firstname">Student's Firstname
<option value="Student Middleinit">Studen'ts Middlename
</select>

If you want to allow your users to choose multiple fields to display, your <select> tag should look like:

<select name="displayfields" multiple>


sortfield select tag If you have included a sortallow option in your configuration file to allow your users to sort search results, you must include an <select> tag with a name of "sortfield". You would then list each header name of the fields in your database as specified in your header record in the database file. The default which describes the sort list must have a value of "0".

<select name="sortfield">
<option value=0 selected>Select field to sort results by
<option value="SSN">Student's SSN
<option value="Ref Lastname">Recommender's Lastname
<option value="Ref Firstname">Recommender's Firstname
<option value="Ref Middleinit">Recommender's Middlename
<option value="Student Lastname">Student's Lastname
<option value="Student Firstname">Student's Firstname
<option value="Student Middleinit">Studen'ts Middlename
</select>




penn web developers
top

Information Systems and Computing
University of Pennsylvania
Comments & Questions


University of Pennsylvania Penn Computing University of Pennsylvania Information Systems & Computing (ISC)
Information Systems and Computing, University of Pennsylvania