Revolutsio Posted May 23, 2022 Share Posted May 23, 2022 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 Quote Link to comment https://forums.phpfreaks.com/topic/314831-add-a-link-to-a-image/ Share on other sites More sharing options...
Barand Posted May 23, 2022 Share Posted May 23, 2022 <a href='page_to_go_to'> <img src='image_file_is_here' > </a> Quote Link to comment https://forums.phpfreaks.com/topic/314831-add-a-link-to-a-image/#findComment-1596574 Share on other sites More sharing options...
Revolutsio Posted May 23, 2022 Author Share Posted May 23, 2022 1 hour ago, Barand said: <a href='page_to_go_to'> <img src='image_file_is_here' > </a> How do i do this with php code as i tried the above code and it did not work Quote Link to comment https://forums.phpfreaks.com/topic/314831-add-a-link-to-a-image/#findComment-1596578 Share on other sites More sharing options...
ginerjm Posted May 23, 2022 Share Posted May 23, 2022 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) Quote Link to comment https://forums.phpfreaks.com/topic/314831-add-a-link-to-a-image/#findComment-1596580 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.