makaveli03 Posted March 9, 2009 Share Posted March 9, 2009 Hi, I am not that PHP literate. I received help in coding my website. I am now tinkering with it to get the final results. Initially, the link was hyperlinked to text, which works, but I want to link it to an image. Heres the code for the text: <?php if ($row [ 'virtualtour' ] ) { print "<a href=\"".$row [ 'virtualtour' ]."\" target=\"new\">Virtual Tour</a>";} ?> Lets say I have an image in the file ../../images/button_virtualtour.jpg How can I link it? When I try this: <?php if ($row [ 'virtualtour' ] ) { print "<a href=\"".$row [ 'virtualtour' ]."\" target=\"new\"><img src="../../images/button_virtualtour.jpg" alt="" /></a>";} ?> It does not work. Can anyone help me? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/148552-solved-hyperlinking-from-an-image-to-open-a-link-stored-in-database/ Share on other sites More sharing options...
.josh Posted March 9, 2009 Share Posted March 9, 2009 You need to escape the double quotes ( \" ) in your image link, just like those other escaped ones in that line, so that php knows that those quotes are not the end of the string to print. Quote Link to comment https://forums.phpfreaks.com/topic/148552-solved-hyperlinking-from-an-image-to-open-a-link-stored-in-database/#findComment-780080 Share on other sites More sharing options...
makaveli03 Posted March 9, 2009 Author Share Posted March 9, 2009 Hey Crayon Violent, At first I was a little confused at what you meant by "escape the double quote". But a second before I replied saying that I didn't know, it kinda clicked. Glad to say that it works! Thanks for the speedy reply. Problem is solved. Quote Link to comment https://forums.phpfreaks.com/topic/148552-solved-hyperlinking-from-an-image-to-open-a-link-stored-in-database/#findComment-780088 Share on other sites More sharing options...
.josh Posted March 9, 2009 Share Posted March 9, 2009 haha sorry, what I probably should have said was "php is looking at the quotes in your image you put in there and it thinks that's the end of the string to print. To tell it that that's not the end of the string, you have to put a \ in front of it, or 'escape' it, so that php knows that's not really the ending " to look for." Quote Link to comment https://forums.phpfreaks.com/topic/148552-solved-hyperlinking-from-an-image-to-open-a-link-stored-in-database/#findComment-780092 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.