Jump to content

Help creating a hyperlink with images stored in variables.....


Recommended Posts

Hello all,

 

Newbie alert !

 

Really stuck on this bit of code, tried a few searches but now more confused  :shrug:

 

I want to create an html table and popluate it with some images, the path of which is the result of a mysql search, I'm tying myself in knots with the basic php/html syntax....

 

This is the current incarnation....

 

print "<tr><td><a href=$imagetoshow><img src=$imagetoshow></a></td><td>$title $subtitle</td><td>$location</td><td>$blurb</td></tr>";

 

 

The images doesn't show, a blank/broken placeholder does show as a hyperlink but not to a url that makes sense.

If I forget the hyperlink bit I can get an image to show fine

 

What am I missing ?

 

Thanks

Mike

 

you have forgotten to place you href and src attributes inside of quotations.

print "<tr><td><a href='$imagetoshow'><img src='$imagetoshow'></a></td><td>$title $subtitle</td><td>$location</td><td>$blurb</td></tr>";

 

Tried that, the image doesn't appear and the URL that is created points at :-   

 

http://www.somewebpage.com/%3Cimg%20src=

 

:(

 

ah I see, that would explain it. Glad you found your error.

 

I don't recommend storing HTML code inside of a variable in the future, causes confusion when incorporating the variable into your code.

 

Yes I'll not do that again !  Thanks

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.