Author |
Topic |
|
Lycaster
New Member
USA
60 Posts |
Posted - 24 April 2001 : 11:04:27
|
I have a search setup with a dynamic drop-down box displaying the "keywords" or in this case the departments of a staff directory. Because some of the Departments/Keywords are more then one word, I have used the ASP function: Server.URLEncode.
This added a "plus" sign where the spaces used to be in a department/keyword.
Example:
"Administrative Staff" is now "Administrative+Staff"
So thats good. The problem is I dont know how to setup my results page to know that "Administrative+Staff" is really "Administrative Staff" and then filter only the appropriate records. It works fine with a single word keyword though.
Here is the code that does the filtering:
Session("Department") = Trim(Request("Department")) Session("Title") = Trim(Request("Title")) Session("FName") = Trim(Request("FName")) Session("LName") = Trim(Request("LName"))
' Department If Session("Department") <> "" Then sFilter = "Department LIKE '%" & Session("Department") & "%'" Else sFilter = "" End If
' Title If Session("Title") <> "" Then If sFilter = "" Then sFilter = "Title LIKE '%" & Session("Title") & "%'" Else sFilter = sFilter & " AND Title LIKE '%" & Session("Title") & "%'" End If End If
' First Name If Session("FName") <> "" Then If sFilter = "" Then sFilter = "[First Name] LIKE '%" & Session("FName") & "%'" Else sFilter = sFilter & " AND [First Name] LIKE '%" & Session("FName") & "%'" End If End If
' Last Name If Session("LName") <> "" Then If sFilter = "" Then sFilter = "[Last Name] LIKE '%" & Session("LName") & "%'" Else sFilter = sFilter & " AND [Last Name] LIKE '%" & Session("LName") & "%'" End If End If
I know this is allot, but can someone please help? Thanks in advance.
- Jared |
|
paco
Junior Member
Spain
187 Posts |
Posted - 24 April 2001 : 11:40:51
|
What about:
department_string = replace (department_string,"+"," ")?
Regards,
Paco
|
|
|
paco
Junior Member
Spain
187 Posts |
Posted - 24 April 2001 : 11:45:46
|
Do you really need Session variables? If you do, try something like:
title = Session ("Title") ... the same for other Session variables
and then use title instead of Session.. your code would be cleaner and pobably more efficient.
Regards,
Paco
Edited by - paco on 24 April 2001 11:48:32 |
|
|
Doug G
Support Moderator
USA
6493 Posts |
Posted - 24 April 2001 : 11:57:06
|
This is why I don't encode data in the database itself. There are other urlencode changes you may end up with other than "+" depending on your data.
====== Doug G ====== |
|
|
Lycaster
New Member
USA
60 Posts |
Posted - 24 April 2001 : 12:30:58
|
When I use Server.URLEncode, anything that has a space in it is replaced with a "+" which is what I expect it to do. Now when passing my string to a filter, like:
action="display.asp?Department=Administrative+Staff"
It is handled by my filter, which is comparing Administrative+Staff to the way it is in the database. In the database it does not have the "+" sign. So the value is:
Administrative Staff
When the filter is applied, It cant find the "+" in the database. Is there a way to fix this, without having to add a plus sign in my database?
|
|
|
paco
Junior Member
Spain
187 Posts |
Posted - 25 April 2001 : 03:07:00
|
If you are just concerned with the + sign, why don't you substitute it with a white space? I think it's all you need.
Paco
|
|
|
Lycaster
New Member
USA
60 Posts |
Posted - 25 April 2001 : 08:27:12
|
A white space what do you mean? |
|
|
paco
Junior Member
Spain
187 Posts |
Posted - 25 April 2001 : 11:59:43
|
Well, my spanish mind came by and I guess it is just a space. What I meant was to use:
result = replace (Session ("Department"),"+"," ")
It will replace +'s with spaces.
Hope this helps, Paco
|
|
|
|
Topic |
|