Hope this helps!!
I knocked this function up which would search through a string and replace words found in the string which exist in a MySQL table.
<?php
function ConvertToGlossaryText($ConvertThis) {
// Get all the glossary terms from the glossary table an store them
// in an array
$GlossaryTerms = array();
$SQLQuery = "SELECT glossary_term_id, term FROM glossary_term_tbl ORDER BY glossary_term_id ASC;";
$Result = mysql_query($SQLQuery);
while ($GlossaryTerms[] = mysql_fetch_array($Result)) {
}
mysql_free_result($Result);
// Replace any word found in the article which exists in the glossary
// array with a reference to the glossary php page
for ($intWords=0; $intWords < count($GlossaryTerms) -1; $intWords++){
$GlossaryID = $GlossaryTerms[$intWords] [0];
$FindThis = $GlossaryTerms[$intWords] [1];
$ReplaceWith = "<A HREF=\"glossary.php?id=$GlossaryID\">$FindThis</A>";
$ConvertThis = eregi_replace ($FindThis, $ReplaceWith, $ConvertThis);
}
return $ConvertThis;
}
Good Luck
BB