有人知道如何从php变量中创建链接吗。我希望我的php变量$LeagueLink是指向leaguehome的链接,其名称是mysql查询的结果。如果可以的话请帮忙。。。。
$result = mysql_query("SELECT League FROM League_Info WHERE User_ID = '$id'");
$result2 = mysql_fetch_array($result);
$result3 = $result2['League'];
$LeagueLink = '<a href="home.com/test.php"><?=$result3?></a>';
最佳答案
$LeagueLink = "<a href=\"http://home.com/leaguehome.php\">$result3</a>";
要将变量直接放入上面这样的字符串中,它需要是双引号字符串(
"
),而不是单引号字符串('
)或者,如果您担心粗心引起的错误,请使用字符串连接:
$LeagueLink = '<a href="http://home.com/leaguehome.php">' . $result3 . '</a>';