Jump to content

add a link to a image


Revolutsio

Recommended Posts

I have a list of images that i show on screen in and what to be able to click on the image and have it go to another page, I can do this with text but not an image

 

<?php echo "<img class='img_two' src='images/" . $game['image'] ."' >"?>

This is the code that just shows the images, i have tried the following

<a href="details.php?id=<img class='img_two' src='images/" . <?php echo $game['image'] ?> 

But does not show anything Please Help

Link to comment
Share on other sites

The way to show an image that is 'clickable' is to write an anchor tab (<a>) that uses an img tag in place of the ordinary text that you might use for an anchor.  Use php code just the same way you would use text.  

$img_name = '/folder/image1.jpg';
echo "<a href='mypath/script.php'><img src='$img_name'></a>";

(My syntax may not be perfect but you should get the idea)

Link to comment
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.