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>";
}
精彩评论