1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

vbscript - auto hyperlink words in content that exist in DB

Discussion in 'C#' started by grobar, Aug 22, 2006.

  1. #1
    in say, a dictionary of terms with definitions, (in a database) how can i hyperlink (automatically) words within the definitions for which a definition also exists.

    url structure is like this

    www.site.com/glossary?word=someword

    Then - in the definition of "someword" there is a word that also has a definition in the database. I'd like to auto hyperlink it to that definition.

    any ideas?
     
    grobar, Aug 22, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    When your running through your loop of text to display find and wrap your word:

    so say your doing a loop and this is what will be outputted:

    www.site.com/glossary?word=someword1
    Copy for someword1

    www.site.com/glossary?word=someword2
    copy for someword2

    www.site.com/glossary?word=someword3
    copy for someword3

    in each loop iteration do a replace(currentCopyBlock, wordTerm, "<a href=""http:www.site.com/glossary?word=" & wordTerm & """>blah</a>")

    this should replace your current wordTerm with anchor around + the word term your looking for :)
     
    ccoonen, Aug 22, 2006 IP
  3. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #3
    if you are talking about something like itellitext does, then you'll need to learn some JavaScript.

    Besides your URLs don't work
     
    ludwig, Aug 22, 2006 IP
  4. grobar

    grobar Well-Known Member

    Messages:
    642
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Thanks! one question though - since the data is all coming from a database, what if one of the words to be replaced has not yet come up in the loop? (...or would it be okay since EVERYTHING should be in the recordset?

    Also - in each copyblock, there could potentially be multiple wordTerms - would this work here too? I'll actually set up an experiment with this one later.

    Thanks again!
     
    grobar, Aug 23, 2006 IP
  5. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    multiple wordterms - just do multiple replaces - take your wordTerms - split it into an array - then run through the array in an inner loop doing replaces.

    If you have data that needs to be checked against, but doesn't exist (yet) - then run through the loop, build an array of terms, then run through the loop again - comparing against the array you just built with the first loop.
     
    ccoonen, Aug 23, 2006 IP
  6. grobar

    grobar Well-Known Member

    Messages:
    642
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #6
    yeah that makes sense. I'm wondering about the efficiency of this though. with an access database with over 1000 terms, couldn't this get resourse intensive?
     
    grobar, Aug 23, 2006 IP
  7. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #7
    a thousand records is nothing, Just remember: GetRows! Create your DB Connection, run your query, if their are more than 0 records, then use the GetRows function to convert your recordset into a 2-dim array. Now close your connection. So before anything is calculated - your DB Connection is already closed :)

    Now it's simply running through loops of arrays that already in memory.

    I can understand your concern though because if you did all your calculations while the DB connection is open - and their are 100 concurrent users - your system will bog down like a mo'fo. Thank God for GetRows :)
     
    ccoonen, Aug 24, 2006 IP