PleaseHelpPlease Posted May 23, 2005 Share Posted May 23, 2005 We have a value in our DB called website, it is in the form www.whatever.com, we want to display as the value in DB but also be a link to that site. this is the code we have, any suggestions? $web = $info['Website']; <a href="$web"></a> Quote Link to comment https://forums.phpfreaks.com/topic/2320-hyperlink-using-php-variable/ Share on other sites More sharing options...
neylitalo Posted May 23, 2005 Share Posted May 23, 2005 One thing that I noticed: <a href="$web"></a> should be: echo("<a href=\"$web\">$web</a>"); I don't know if you just left the echo out or what, but that line should work... with $web being www.example.com: output is <a href="www.example.com">www.example.com</a> neylitalo Quote Link to comment https://forums.phpfreaks.com/topic/2320-hyperlink-using-php-variable/#findComment-7603 Share on other sites More sharing options...
Pilot-Doofy Posted May 29, 2005 Share Posted May 29, 2005 echo("<a href=\"$web\">$web</a>"); The parentheses aren't need and why use escape characters when they're not needed? I wouldn't suggest hiding variables inside of double quotes, at least not when you're using Dreamweaver because Dreamweaver won't highlight variables inside of quotes. I just don't believe it's a good habit to get into. echo '<a href="' . $web . '">' . $web . '</a>'; If you know that your contents are going to involve only one style of quotes it's much simpler just to prevent escape characters and march on with the contradicting style for opening and closing the statement. Quote Link to comment https://forums.phpfreaks.com/topic/2320-hyperlink-using-php-variable/#findComment-7648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.