Lesson 12. Building Search Interfaces

It's time to complete the tour search application you began in Lesson 11. There, you built tour_detail.asp, which displays all of the tours in an unfiltered format. In this lesson, you will build a search page that enables users to search tours in three different ways: show all, show by world region, and show by country.

The challenge is to create three independent means of searching tours, all while showing the results on the same page (tour_detail.asp). The search page (tours.asp) will contain three ways of accessing tour_detail.asp. One way is a simple URL with no URL parameters, which will show tour_detail.asp unfiltered (that is, the way it currently exists). The second is to use a URL that has additional URL variables. And the third is to access the page by submitting a form, which passes form variables. Both URL and form variables will be used to filter the recordset dynamically.

To get these three different ways of getting tour_detail.asp to work, you need to set up a script in tour_detail.asp that reacts differently depending on whether it is accessed with no data (the first way), accessed with URL parameters (the second way), or accessed with form variables (the third way). The script will know how to filter the query that displays the tour description(s) based on the presence or absence of URL and form variables.

In this lesson, you will go behind the GUI once again and work extensively with code, especially SQL code.

graphics/12inf01.gif

This may sound confusing at this early stage, but you have done most of the tasks involved in this lesson beforejust never all of them together. But it's the ability to creatively combine the different techniques you learn, as well as the ability to tweak code by hand when necessary, that defines competence in ASP or ColdFusion. In this lesson you will send and receive URL and form variables, hand-code SQL, write a nested if…else block to determine which of three SQL queries to run, use comments, and use IsEmpty() (ASP) or IsDefined() (ColdFusion) to determine the presence of variables.

WHAT YOU WILL LEARN

In this lesson, you will:

  • Build a dynamic search interface that lets users search and filter data in three different ways

  • Hand-code several SQL queries using joins, dynamically filtered data, and subqueries

  • Show or hide the Recordset Navigation Bar, based on need

  • Temporarily disable code using comments for testing and debugging

  • Use built-in functions to check for the presence of URL and form variables

  • Use nested if…else blocks to create a sophisticated flow control structure

APPROXIMATE TIME

This lesson takes approximately two hours and 30 minutes to complete.

LESSON FILES

Starting Files:

Lesson12/Start/newland/tours.asp

Lesson12/Start/newland/tour_detail.asp

Completed Files:

Lesson12/Complete/newland/tours.asp

Lesson12/Complete/newland/tour_detail.asp