Hi I have two sets of PHP code: The First one here is a function that will automatically give me a link for text that is displays and it seems I would normally call it using something like this
autolinks ("THIS IS THE PLACE IT SEARCHES TO REPLACE TEXT");
<?php
function autolinks ($message)
{
$filename = "autolinks.db.txt";
$handle = fopen($filename, "r");
$lstuff = fread($handle, filesize($filename));
fclose($handle);
$lstuff2=explode("|", $lstuff);
$lcount=count($lstuff2);
$i=1;
while ($i <= $lcount)
{
$lstuff3=explode(",", $lstuff2[$i]);
$noendspace=explode(" ", $lstuff3[0]);
$countspacething=count($noendspace);
$spacenum=$countspacething-1;
if ($countspacething > 1)
{
$j=0;
$wordnow="";
while ($j < $spacenum)
{
$wordnow=$wordnow." ".$noendspace[$j];
$j++;
}
$message=str_replace($lstuff3[0], "<a class=autolinks href=$lstuff3[1] target=blank>$wordnow</a> ", $message);
}
else
{
$message=str_replace($lstuff3[0], "<a class=autolinks href=$lstuff3[1] target=blank>$lstuff3[0]</a>", $message);
}
$i++;
}
echo "$message";
}
?>
But, The text that I am using is coming from a database like this:
while($row = mysql_fetch_array($result))
{
echo '<strong><center><font size=5>';
echo $row['title'];
echo '</strong></center></font><br><font size=4>';
echo $row ['body'];
echo '<br></font>';
echo '<br/><a href="http://www.';
echo $row['linq'];
echo '">';
echo $row['linqtitle'];
echo '</a>';
echo '<br/><a href="http://www.';
echo $row['rlink'];
echo '">';
echo '<br/><br/>';
echo 'Return Link</a>';
}
echo '<br><center>';
Is there a way for me to to do the same thing where the 'BODY' var in the second code is the code that the autolinks uses to find the words to replace with the hyperlink?
Thank you so much for any advice I just can't seem to work this one out.
Michael