• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 12. Building Search Interfaces > Switching SQL Statements According to E...

Switching SQL Statements According to Environmental Variables

You know from testing that each of the interfaces works—as long as two of the SQL statements are commented out. That setup is just fine for testing, when you can open the document and apply the correct commenting based on your needs, but obviously it needs help before it can go into production. You need an automated way of switching the query based on the type of search. Your first task is to identify how tour_detail.asp will know which search type the user has chosen. Then, based on that, you need to swap in the proper SQL statement. An if…else construct is perfect for swapping the correct SQL statement in, but how does it know which search type the user submitted?

Back in a previous lesson, you implemented server-side form validation. The way it worked was that it checked to see whether a form variable called numadults or numchildren existed and was numeric. If it didn't exist, or it wasn't numeric, the user was redirected back to the form on the tour price page to fix the problem. I remind you of this because it provides a strategy for determining which search type the user selected: Check for the presence or absence of certain variables, as follows:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint