开发者

PHP/MySQL Link Each Word

I have a PHP scri开发者_高级运维pt that pulls keywords from a MySQL database and I need help with figuring out how to link each word.

An example MySQL entry: cow moo white black

Need to output in link form:

<a href=word.php?word=cow>cow</a> <a href=word.php?word=moo>moo</a>, etc.

Thank you


Try this:

$output = "";
$mysql_str = "cow moo white black";
$keywords = explode(" ", $mysql_str);

foreach ($keywords as $keyword) {
  $output .= "<a href=\"word.php?word=".$keyword."\">".$keyword."</a> ";
}

echo $output;


If $row["entry"] is the entry, then as follows:

   $fieldArray = split(" ", $row["entry"]);

    foreach($fieldArray as $item) {
      echo "<a href=\"word.php?word=" . $item . "\">" . $item . "</a>";
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜