Hello all!
I have the following code:
<?php
$connection = mysql_connect("localhost","user","pass") or die ("Couldn't connect!");
$db = mysql_select_db("database",$connection) or die ("Couldn't execute query!");
$query = "select * from texts where (text like '%$searchword%')";
$query = mysql_query($query,$db);
while($text_row = mysql_fetch_array($query)) {
$text = $text_row["text"];
$search_query = "select subjects from search";
$search_query = mysql_query($search_query,$db);
while($search_row = mysql_fetch_array($search_query)) {
$search = $search_row["subjects"];
}
$new_text =ereg_replace("([A-Za-z0-9]|)((($search)([A-Za-z0-9]|$))+)", "\1<a href=$PHP_SELF?entry=$search>\2</a>", $text);
}
echo $new_text;
?>
which is supposed to put a hyperlink around all occurances of any words in $search in the resulting text, $new_text. but it only links all the occurances of the LAST row of $search in the resulting $new_text...... any suggestions?
Thanks in advance!
Robert