Forum Moderators: coopster
I have a list of terms and my client want their content to have links to the term description if a term(which is in the terms list) appears in the content of their site
I know this is done allot on sites but the only way i can thing is to do a replace thru the content but think I would need to do a find/replace 100 times if there where 100 words in the terms list (hope that makes sense)
They want this automatic, not opting themselves what words to link via the cms, which is how I was going to do it using xsl/xml etc
Example
"This is a <link>term</link> within content"
But they want content to stay
"This is a term within content"
and when view on webpage turn into
"This is a <a href="etc">term</a> within content
Does anyone know of a neat solution?
Thanks
Trent
note: I shortened this down to make it easier to read so I hope i didn't make any errors.
//query database to find names for replacing$replace = "SELECT firstname, lastname, playerid
FROM players";
$result = mysql_query($replace);//put results into an array
while($row = mysql_fetch_row($result)) {
$myArray[$row[0]." ".$row[1]] = "<a href='page.php?playerid=".$row[2]."'>".$row[0]." ".$row[1]."</a>";
}//query database to find text to display
$query_recap = "SELECT *
FROM recaps
WHERE `dateid` = something
LIMIT 0,1";
$recap = mysql_query($query_recap, $connectDB) or die(mysql_error());
$row_recap = mysql_fetch_assoc($recap);//echo text replacing keys with values
echo str_replace(array_keys($myArray), array_values($myArray), nl2br($row_recap["text"]));