Does anyone know how to make a link out of a php variable. I want my php variable $LeagueLink to be a link to leaguehome with the name of the result of a mysql query. Please help if you can....
$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>";
To place variables directly into a string like above, it needs to be a double quote string ("
), not a single quote string ('
)
Or, if you're worried about carelessness-provoked errors, use string concatenation:
$LeagueLink = '<a href="http://home.com/leaguehome.php">' . $result3 . '</a>';
You can also do this
$LeagueLink = '<a href="home.com/leaguehome.php">'.$result3.'</a>';