sildona Posted October 25, 2012 Share Posted October 25, 2012 The following echo "<img src='".$image."' height='200px' />"; shows an image from a database. How do I get a link to automatically add itself to the image? I would have to enter the URL address into the database and call that address into a variable then href=$linkvariable to the above img source. Correct? Link to comment https://forums.phpfreaks.com/topic/269909-need-help-adding-href-to-a-variable/ Share on other sites More sharing options...
Jessica Posted October 25, 2012 Share Posted October 25, 2012 Yes, store the url in the database, then just echo the html for the link around the image. Link to comment https://forums.phpfreaks.com/topic/269909-need-help-adding-href-to-a-variable/#findComment-1387711 Share on other sites More sharing options...
Psycho Posted October 25, 2012 Share Posted October 25, 2012 Your question is a bit confusing. If you are wanting the image to be a hyperlink to just the image then all you need to do is this. echo "<a href='{$image}'><img src='{$image}' height='200px' /></a>"; Link to comment https://forums.phpfreaks.com/topic/269909-need-help-adding-href-to-a-variable/#findComment-1387712 Share on other sites More sharing options...
sildona Posted October 25, 2012 Author Share Posted October 25, 2012 Sorry, Psycho! Thanks Jessica! Yes ... an image linked to a URL rather than an image linked to another version of itself. Link to comment https://forums.phpfreaks.com/topic/269909-need-help-adding-href-to-a-variable/#findComment-1387718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.