Jump to content

[SOLVED] Hyperlinking from an Image to open a link stored in database


Recommended Posts

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.

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.

;D

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."

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.