在回声中使用“a href”

时间:2015-04-20 12:57:07

标签: php html

我正在尝试打印链接列表,这意味着我需要在第3行使用href,但我不知道在这种情况下语法应该如何。此外,链接是PHP变量。

$sql = mysql_query("select nm_linha from linhas where cidades_origem like '%$cod_cidades%'");
while($exibe = mysql_fetch_assoc($sql)){
echo $exibe['nm_linha'] .'<br>';
}

2 个答案:

答案 0 :(得分:1)

    $sql = mysql_query("select nm_linha from linhas where cidades_origem like '%$cod_cidades%'");
while($exibe = mysql_fetch_assoc($sql)){
echo "<a href='link.html'>".$exibe['nm_linha'] ."</a><br>";
}

答案 1 :(得分:0)

$sql = mysql_query("select nm_linha from linhas where cidades_origem like '%$cod_cidades%'");
while($exibe = mysql_fetch_assoc($sql)){
echo '<a href='".$exibe['nm_linha']."'>'.$exibe['nm_linha'].'</a><br>';
}

这将列出链接以及点击它时被重定向到相应的链接。 试试这个。

相关问题