Pre-defined Searches

Example

Searching for sleeveless t-shirts in the Clothing database.

MGI Tags

  • mgiSearchDatabase

Steps

  1. Open the search format file in a text editor.
  2. Enter a hidden, pre-defined search field.
  3. Save the search format file.
  4. FTP the search format file to the web server running MGI.
  5. View the search page in a browser and perform a search.


Step 1: Open the search format file in a text editor.

Open the search format file (searchformat.txt) in a text editing program that allows you to view and modify the HTML.

Step 2: Enter a hidden, pre-defined search field.

Pre-defined searches are performed with hidden input fields. The hidden input field defines the search criteria (the database field name and the value) so that specific results will be displayed when the search button is clicked.
 
In the name of the hidden input, use the name="field=DatabaseFieldName" syntax where "DatabaseFieldName" is the name of the database field to search. In the value of the hidden input, enter the search criteria.
<input type="hidden" name="Description" value="Sleeveless">
The maximum number of results per page can be pre-defined with a hidden input also. Name the hidden input "mgiSearchDatabaseResultsLimit". Enter the maximum results per page in the value of the hidden input.
<input type="hidden" name="mgiSearchDatabaseResultsLimit" value="10">
The following is a search format file with pre-defined searches and result limits.
<CENTER>
<TABLE WIDTH="250">
<TR><TD><p>Click the search button to see all 
of our Sleeveless t-shirts.</p></TD></TR>
<TR><TD><p>
<input type="hidden" name="Description" value="Sleeveless">
<input type="hidden" name="mgiSearchDatabaseResultsLimit" value="10">
<mgiGet name="mgiSearchButton"></p></TD></TR>
</TABLE>
</CENTER>

Step 3: Save the search format file.

Save the changes you have made to the search format file.

Step 4: FTP the search format file to the web server running MGI.

Upload the search format filele to the web server using an FTP program.

Step 5: View the search page in a browser and perform a search.

View the search page in a web browser. The sentence "Click the search button to see all of our Sleeveless t-shirts" and the search button display. Click the search button and all products with the word "Sleeveless" in the description field are returned 10 products per page.


[Return to the Searching Databases and Displaying Results Menu]


[User Guide Main Menu] [Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]