Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search function on web site

Status
Not open for further replies.

pinkpoppy

Programmer
Jul 6, 2011
75
0
0
US
Hi there,
I have a search function on my web site and am trying to figure why this code does not work. The search function needs to accept numbers 0 to 9, letters a to z, cap letters A to Z, spaces, no spaces, and dashes. Right now the function accepts all but am having problems with search term that contains numbers and letters.

For example, one of the search term in the database is: W12-543-TR-G5-2001

So when a user searches for that particular data, entering "W12-543-TR-G5-2001" or "W12543TRG52001" should render the results. My current codes is not accepting these terms.

string searchterm= "";
for (int i = 0; i < _keyword.Length; i++)
{
if ((_keyword >= 'a' && _keyword <= 'z') || (_keyword >= 'A' && _keyword <= 'Z') || (_keyword >= '0' && _keyword <= '9') || _keyword == ' ' || _keyword == '-')
{
searchterm+= _keyword;
}
}
_keyword = searchterm;

Any help or suggestions is greatly appreciated!
 
Searching should be done in the database. You need to determine if there is a set structure for your data, in other words, how it is stored in the db. Then you have to construct your search parameters to search your DB correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top