[thelist] Help with a replace loop

Shinji Kuwayama shinji at kuwayama.com
Tue Jun 12 11:53:36 CDT 2001


on 6/12/01 11:33 AM, sarah at disaster7 at yahoo.com wrote:

> My guess is that you have repeats of the terms coming
> from the database. Otherwise it shouldn't do that, but
> it will if you are checking for the same term twice.
> Is that a possibility?

Hi Sarah! The terms are unique; what's happening is that terms sometimes
appear inside the #definition# of other terms. So if the query returned:

Terms:      Definitions:
e-mail      a way of sending messages over the Internet
Internet    a global network of computers

The code produces this:

<a href="[url]" title="a way of sending messages over the <a href="[url]"
title="a global network of computers">Internet</a>">E-mail</a> is the most
popular part of the Internet.

So that's the basic problem. What would you do?

Here's the code again:

<cfloop query="getTerms">
    <cfif FindNoCase(#term#,varcopy) is not 0>
        <cfset varcopy = ReplaceNoCase(varcopy,#term#,'<a
href="http:///term.cfm/#term_id#.cfm"
title="#definition#">#term#</a>',"ALL")>
    </cfif>    
</cfloop>

-- 
Shinji Kuwayama
Director, Internet Development
http://www.internetcoach.com/





More information about the thelist mailing list