Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Searching with an encoded string HELP?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lycaster
New Member

USA
60 Posts

Posted - 24 April 2001 :  11:04:27  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
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  Show Profile
What about:

department_string = replace (department_string,"+"," ")?

Regards,

Paco

Go to Top of Page

paco
Junior Member

Spain
187 Posts

Posted - 24 April 2001 :  11:45:46  Show Profile
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
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 24 April 2001 :  11:57:06  Show Profile
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
======
Go to Top of Page

Lycaster
New Member

USA
60 Posts

Posted - 24 April 2001 :  12:30:58  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
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?

Go to Top of Page

paco
Junior Member

Spain
187 Posts

Posted - 25 April 2001 :  03:07:00  Show Profile
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


Go to Top of Page

Lycaster
New Member

USA
60 Posts

Posted - 25 April 2001 :  08:27:12  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
A white space what do you mean?
Go to Top of Page

paco
Junior Member

Spain
187 Posts

Posted - 25 April 2001 :  11:59:43  Show Profile
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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07