Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Searching articles for hand-picked keywords, Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
15 active users
31 visitors today
115 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

The Search.asp SSI

The search form is a perfect candidate for a Server Side Include. The form can be included on a standalone search page, placed on the navigation bar, or even in a rotating banner.

I implemented just one function, ProcessSearch( ). The framework of the function is shown below.

// ============================================
// display search form, bQuiet will suppress introductory text
// ============================================
function ProcessSearch ( bQuiet )
{
   // has the form been submitted?
   if ( Request.Form.Count )
   {
      // get data from form
      // perform search
      // display results
   }
   else
   {
      // explain search form
   }

   // display search form, even after search
   Out ( '<form action="Search.asp" method="post">' );
      Out ( '<input type="text" name="SearchText" size="20">' );
      Out ( '<input type="submit" value="Search">' );
   Out ( '</form>' );
}

This single function does everything - display the form, process the form, query the database and display the results. Just call ProcessSearch( ) from anywhere in your code, any it'll appear. In fact, I'll demonstrate...Use this form to search through the articles on CoverYourASP. You are searching through a database of keywords that I hand-picked for each page.

Please bear in mind that this is only the first stage of adding a search capability to the site - there is no way yet to search for "a AND b". If you enter multiple words I will return results that match any of them.

Tip: You don't have to type all of the words you're searching for - you can type "ad", not "advertising", or "appl" instead of "application variables".

 

Part 3: Creating the SQL statement...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...