Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - spliting the data in a field
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

spliting the data in a field

 Post Reply Post Reply
Author
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Topic: spliting the data in a field
    Posted: 16 February 2003 at 10:43pm

Ok,

I have a field with keywords separated with comas.

I want to make links with each of these words in the strings, how can I separate them and do this?

Example:

Keywords: biodiversity, climate change, policy, ozone

I want links like that:

search.asp?biodiversity

search.asp?climate change

search.asp?policy

search.asp?ozone

 

I want to put that in my news app (a modified version of the old news app from here), so people can search directly in my DB from subjects close to the ones present in the news they just read.

But I have no idea how I can separate these... I and don't want to create a lot of keywords fields... is that possible?

Thanks again people!



Edited by faubo
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2003 at 12:05am

Something like:
<%
thisstring = xxxxxxxx  'Whatever your comma seperated string is
thisarray = Split(Trim(thisstring), ",")
For i = LBound(thisarray) To UBound(thisarray)
 Response.Write <a href=&quot;search.asp?search=" & thisarray(i) & "&quot;>" & thisarray(i) & "</a>" "<br>"
Next
%>

OK, I am pretty tired so check I got the quotes right....should work for you though

Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2003 at 10:25pm

Thanks Michael, I will try that,

I got the idea, if didn't work I will mess around and find the right way

Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 1:07am

Ok, I almost made it.

Everything is working as they should, the only problem is when I have a keyword that are more than one actually, like "Climate Change" the link for this keywork is with only the first word in the string, it's only .asp?Climate in this example.   

Is there any way to solve this?

Thanks again.

btw, here is the code with the correct quotes: 

<%
     
thisstring = rsNews("pchave")
thisarray = Split(Trim(thisstring), ", ")
For i = LBound(thisarray) To UBound(thisarray)
 Response.Write"<a href=procura.asp?" & thisarray(i) & ">" & thisarray(i) & "</a> <br>"
Next
%>

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 2:36am

Michael has split using the comma as delimter, so any 2 word phrases would still be in the array. I assume its being left off due to being put into the querystring without encoding.

Try urlEncoding() the value thisarray(i) as you build the link and it should work.

Cheers,
A

 



Edited by Bunce
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 10:45am
Full code:
<%   
thisstring = rsNews("pchave")
For each item in Split(Trim(thisstring), ",")
   Response.Write"<a href=""procura.asp?" & Server.URLEncode(trim(item)) & """>" & item & "</a>
"
Next
%>
notice it just splits on "," instead of ", " just in case there aren't spaces around, the trim() inside the loop will take care of white space

Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 1:25pm

Ok, just spent one hour trying to make URLEncode to work, I read Bunce Post before MorningZ write his.

Anyway, thanks guys! The code is working, bu I'm still having a problem,

the URLEncode is making my composite keywords Like this "Climate+Change"

Shouldn't be "Climate%20Change"?

My search page is a very bad one, I think I will hold on all of this and learn how to do it right, I will take a closer look in Borg's Internet Search Engine.

But now I have my real work to do, see you later.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 2:02pm
Originally posted by faubo faubo wrote:


the URLEncode is making my composite keywords Like this "Climate+Change"



when you read and display the data, it'll "unencode it" automatically....

as an example... check out this link (copy an paste it into the address line on a browser

http://www.team-integra.net/index.asp?PageMsg=Hello+there+faubo

Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.