thriller372 Posted February 27, 2015 Share Posted February 27, 2015 Hi,I have an image url stored in a database, I can display the image no problem using this code: echo '<td><img src="'.$row['thumb'].'"></td>'; I am trying to use a variable as a link when you click on the image, as so: <a href='showthumb.php?thumb=$clientthumb'></a> I can use the image as a link but the $clienthumb variable does not show the value of the variable, for example: I get the image with a link of showthumb.php?thumb=$clientthumb but I need The image with a link of showthumb.php?thumb=1 (the number one is $clientthumb value) echo '<td><img src="'.$row['thumb'].'"></td>'; <a href='showthumb.php?thumb=$clientthumb'></a> Link to comment https://forums.phpfreaks.com/topic/294934-image-as-a-link/ Share on other sites More sharing options...
Barand Posted February 27, 2015 Share Posted February 27, 2015 You need to put the string inside double quotes to expand variable values echo "<td><a href='showthumb.php?thumb=$clientthumb'><img src='{$row['thumb']}' /></a></td>"; see http://php.net/manual/en/language.types.string.php Link to comment https://forums.phpfreaks.com/topic/294934-image-as-a-link/#findComment-1506917 Share on other sites More sharing options...
thriller372 Posted February 27, 2015 Author Share Posted February 27, 2015 Fantastic and so simple works a treat, I'd spent nearly two days on this (I like to try and work it out for myself) and got nowhere.You lot make it all seem so simple Cheers Link to comment https://forums.phpfreaks.com/topic/294934-image-as-a-link/#findComment-1506982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.