Welcome to WebmasterWorld Guest from 18.232.124.77

Forum Moderators: ocean10000

Message Too Old, No Replies

Making keyword hyperlinks separated by comma? Classic ASP

I need to make keyword hyperlinks that go to a search results page when...

     
8:17 am on Sep 18, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


Hi,
I wonder can anyone help me here. I need to make keyword hyperlinks that go to a search results page when they are clicked - using the keyword as a search query.

So for instance, you will have a number of users who enter keywords on their accounts which are separated by commas (example: music, dance, chat, property).

When someone looks at a user profile they will see those words as links that they can click on and find other users with those keywords.

I know everything else, I just need to know how to make the keywords show up as links.

I am using an Access dbase as this is just a test phase. Can I use a 'memo' field?

If anyone has any info or links to somewhere that has info please let me know.

Any questions just give me a bell.

Thanks for any help.

8:28 am on Sept 18, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


I'm not sure if I have understood correctly, but if you have stored the keywords as a comma separated list and have retrieved it from the Database, you could split them at the comma and then create links from them.

Something like this:
Add a literal to the Page <asp:Literal ID="Literal1" runat="server" />

Add this to the Code Behind

string myKeywords = "music, dance, chat, property"; // this would come from the DB
string[] myList = myKeywords.Split(','); // Split the keywords
foreach (string myKeyword in myList)
{
Literal1.Text += String.Format("<a href='/search.aspx?query={0}'>{0}</a>, ", myKeyword.Trim());
}

[edited by: marcel at 9:03 am (utc) on Sep. 18, 2009]

8:45 am on Sept 18, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


Sorry I should have been more clear. I'm looking for the Classic ASP code.

Here is an example of what I'm looking for. I hope I can post links like this, if not, I apologise. If you go <snip> and scroll down to the 'Services' > 'I have' and 'I want' area you can see what I mean.

I know the sites not in C ASP but these words have all been entered into a text area and show up as links.

I hope this gives you a better idea of what I'm looking for.

[edited by: marcel at 8:48 am (utc) on Sep. 18, 2009]
[edit reason] Removed URL [/edit]

8:59 am on Sept 18, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


Sorry, I had to remove the URL as they are not allowed here as per forum charter [webmasterworld.com]. I have also edited the Title for you to make it clearer that this is for Classic ASP.

Basically I would still do the same, save all of the keywords in a database field as a comma separated list, and then create URL's from them as they are retrieved from the Database.

Something like this:

Dim myKeywords
myKeywords = "music, dance, chat, property"

Dim myKeywordArray
myKeywordArray = Split(myKeywords, ",")

For i = 0 to UBound(myKeywordArray)
response.write "<a href='/Search.asp?query=" & Trim(myKeywordArray(i)) & "'>" & Trim(myKeywordArray(i)) & "</a>, "
Next

9:26 am on Sept 18, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


Cool, thanks Marcel. I'll try that.

Thanks again.

8:06 pm on Sept 20, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts: 108
votes: 0


I used this code for my page and it worked absolutely perfectly (Thank You!). Only problem is now I'm having trouble creating a Search Results (search.asp) page for it because the above is querying a field that is also a memo field with keywords separated by commas.

I tried searching for the records where the keywords field was like my keyword but because there are a number of keywords, again, separated by commas it is giving me a cannot find record error.

Does anyone know of a way I can code the search results page? This is an area I haven't really ventured into so I'm not 100% on it.

Please help :(

8:19 pm on Sept 20, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 11, 2009
posts:108
votes: 0



Oh, no need. I worked it out! It turns out (as I'm sure you would know) my scripts were a lot more complex than they needed to be.

Thanks for all your help guys. Great forum.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members