我有以下代码:
$result = mysql_query("SELECT link, notes FROM links WHERE username='will';");
$html .= "<ul>";
while ($row = mysql_fetch_array($result)) { //loop
extract($row);
$html .= "<li>{$link} - {$notes}</li>";
}
我需要它说的位 {$link}
成为可打开新窗口的可点击链接。我该怎么做?
当我在它周围放置标签时,您会收到此错误:
错误是:Parse error: syntax error, unexpected '{' in/data/www/vhosts/themacsplash.com/httpdocs/ClipBoy/will.php on line 18
第 18 行是 $html .= "<li>{$link} - {$notes}</li>";
最佳答案
一般情况下,您会创建这样的链接:<a href="URL">link title</a>
.所以在你的情况下是这样的:
$html .= "<li><a href=\"{$link}\" target=\"_blank\">{$link}</a> - {$notes}</li>";
关于php - 创建一个 HTML/PHP 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5283595/