Jump to content

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


judda

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.