judda Posted June 28, 2011 Share Posted June 28, 2011 Hello all, Newbie alert ! Really stuck on this bit of code, tried a few searches but now more confused 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 Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/ Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235839 Share on other sites More sharing options...
judda Posted June 28, 2011 Author Share Posted June 28, 2011 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= Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235846 Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 can you show more code where you set your $imagetoshow variable Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235850 Share on other sites More sharing options...
judda Posted June 28, 2011 Author Share Posted June 28, 2011 can you show more code where you set your $imagetoshow variable Thanks Fugix, your comment cause an 'Argh of course !' moment, my $imagetoshow variable was already packed with <img src=...etc..etc ! Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235856 Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235858 Share on other sites More sharing options...
judda Posted June 28, 2011 Author Share Posted June 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/240607-help-creating-a-hyperlink-with-images-stored-in-variables/#findComment-1235859 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.