ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
179 active users
3160 visitors today
3077 pages today
(only part of today)
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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

Selling products online - read how James does it now



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!