Jump to content

image as a link .....


Go to solution Solved by Barand,

Recommended Posts

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

  • Solution

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

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.