Hey, I’ve got this query and result from a mysql database:
$result = mysql_query(“SELECT * FROM stories WHERE showonpage=’$pageid’ and auth_lvl like ‘$auth_lvl’ and published=’1′ ORDER BY $sort $order”);
while ($row = mysql_fetch_array($result)) {
$postlist[] = array(
‘body’ => $row[‘body’],
‘title’ => $row[‘title’],
‘author’ => $row[‘author’],
‘date’ => $row[‘date’],
‘time’ => $row[‘time’],
‘icon’ => $row[‘icon’],
‘details’ => $row[‘showdetails’]
);
[B]And then I got something like this
$result = Mysql_query (“SELECT * from glossary”);
$num = mysql_num_rows($result);
$i = 0;
while ($i < $num){
$target = mysql_result( $result,$i,’target’);
$title = mysql_result( $result,$i,’title’);
$anchor = mysql_result( $result,$i,’anchor’);
$postlist[‘body’] = str_replace(“$target”, “<a href=”$glossary_page#
$i++;
}
Basically what should happen is this: First all posts are pulled from the database, then all glossary entries should be pulled from another table. When this is done, all words that are in the postbody that are also in the glossary table should be replaced by a link that has the $title and $anchor from the glossary table.
This script however doesn’t seem to work, do any of you know how to get it working?