SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 21st, 2003, 05:22 AM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
search box

I am relatively new to asp so still need help on it.
On my site I have a search that allows users to search for a specific job skill ie.cobol, asp etc...

The problem is that at the moment the search can only search for what is exactly typed in the box eg.

"ASP" this search works fine,
"ASP, HTML" this doesnt because It searches for what is typed in.

I have been told It is something to do with parsing and that this will allow me to search for multiple job skills using commas to split what is typed in. If any body has any ideas I will be very greatfull.

Thanks

Last edited by gintom : September 21st, 2003 at 05:24 AM.

Reply With Quote
  #2  
Old September 21st, 2003, 06:20 AM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
What you need to do is to split all the "pieces" or individual keywords, and then string them together to make a "WHERE" statement that checks against each of the pieces. This is usually done with a boolean flag which indicates if you want to use "OR" or "AND" to separate the conditions (any of the words, or al of the words respectively).
I use a routine like:
Code:
		strSplit = split (TitVal) ' value to search for in title
		For i = 0 To UBound(strSplit)
			if (strSplit(i) <> "") and (strSplit(i) <> " ") Then
				sql_where = sql_where & " TitTxt like '%" & cln_txt(strSplit(i)) & "%'   " & TitTip
				' TitTxt is my title text field, and TitTip is the boolean value from the form, either AND or OR
				' cln_txt is a function I use to trim beginning and end spaces, substitute odd characters, etc.
			End If
		Next 'i
This will need to be incorporated into the SQL construction to create the conditional WHERE part, if there are any other conditions they get put in before or after.

Reply With Quote
  #3  
Old September 21st, 2003, 06:44 AM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
Thanks for the example "OldJacques" but how do I extend it to search further arrays, just incase the user puts in 4 search words eg. cobol, html, asp, javascript?

This is the code that I have, I know that this is basic compared to what else I could do but, this is all I know at the moment. In the search I can retrieve the first search word but not the second, third.....

Is there a way to extend the building of the SQL statement to include all the valid element from the Array but not using empty.
Code:
<%

dim ArrayName

ArrayName = split(Request.form ("search"),",")

%>

<%
' Display Product Types

SQL = "SELECT * FROM jobs Where description Like " & "'%" & ArrayName(0) & "%'"            
 set Rs = Conn.Execute(SQL)
%>

Reply With Quote
  #4  
Old September 21st, 2003, 07:02 AM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Quote:
Originally posted by gintom
Thanks for the example "OldJacques" but how do I extend it to search further arrays, just incase the user puts in 4 search words eg. cobol, html, asp, javascript?...Is there a way to extend the building of the SQL statement to include all the valid element from the Array but not using empty.
Actually the example I provided used the for/next loop to run through as many elements as are found (1, 4, +++) in the string's "split" array. You will need to use your split syntax (mine used only the space character " " but yours will work fine, and search for substrings as well).

Reply With Quote
  #5  
Old September 21st, 2003, 02:04 PM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
I have got the coding to work to begin the search for the elements in the search but the problem that I am having now is trying to actually put it into a SQL statement.

This code does the parsing side of it. This all works fine.
Code:

<%
strSplit = split(Request.form ("search"),",") ' value to search for in title
Dim iNext
For i = 0 To UBound(strSplit)
  if (strSplit(i) <> "") and (strSplit(i) <> " ") Then
    if (i=0) then
      Booltxt="WHERE "
    Else
      Booltxt="OR "
    End If
    sql_where = sql_where & Booltxt & " description like '%" & strSplit(i) & "%'   " 
    ' TitTxt is my title text field, and TitTip is the boolean value from the form, either AND or OR
    ' cln_txt is a function I use to trim beginning and end spaces, substitute odd characters, etc.
  End If
Next 'i

Response.Write(sql_where & "<BR>")

%>


But the part I am having difficulties with is the SQL string (below)
I am trying to put the parsing string where these are:********************** But not having much luck.
Code:
<%
' Display Product Types


SQL = "SELECT * FROM jobs ********************** "            
 set Rs = Conn.Execute(SQL)

Response.Write(SQL & "<BR>")
%>


Once again any help or ideas will be much appreciated.

Tom

Reply With Quote
  #6  
Old September 21st, 2003, 03:13 PM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Maybe I don't understand, or maybe you need a short break, but the solution should be to use
Code:
SQL = "SELECT * FROM jobs " & sql_where
as far as I can see.

what is:
Response.Write(SQL & "<BR>")
giving you?

Reply With Quote
  #7  
Old September 21st, 2003, 03:45 PM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
Quote:
Originally posted by OldJacques

what is:
Response.Write(SQL & "<BR>")
giving you? [/B]


it is giving th following

SELECT * FROM jobs (what ever is typed in here eg sql_where)

Reply With Quote
  #8  
Old September 21st, 2003, 03:50 PM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
its work now mate thank you very much, perhaps I will go for that break now.

Reply With Quote
  #9  
Old September 21st, 2003, 03:52 PM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Sounds like you are putting it inside the quotes, like SQL = "SELECT * FROM jobs sql_where" instead of SQL = "SELECT * FROM jobs " & sql_where & " " or similar

Reply With Quote
  #10  
Old September 21st, 2003, 03:53 PM
gintom gintom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Essex, UK
Posts: 164 gintom User rank is Private First Class (20 - 50 Reputation Level)gintom User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 16 m 46 sec
Reputation Power: 5
thats exactly what I was doing

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > search box


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway