Jump to content

image with automatic generated back link or button


cljones81

Recommended Posts

Hi

 

I have written a simple php script that outputs a thumbnail version of pics with information from a mysql database which when the user clicks the smaller image, a larger image is opened in a new window. My problem is I would like to have an automatically generated button below the bigger image that returns the viewer back to the previous page of thumbnail images.

 

Could someone please help me as I haven't the first clue how to do this and cannot find any tutorials.

 

Thank you in advance

Christian

Thank you for the reply, Im a bit confused, maybe its the affect of a long day finally catching up on me but could you please explain more fully:

 

here is my code:

 

  while  ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$id = $row["id"];
$description = $row["description"];
$category = $row["category"];
$dateuploaded = $row["dateuploaded"];
$url = $row['link'];
$uploader = $row["uploaderid"];   
$compurl = "<a href='$url'><img src='$url' alt='Click me for a larger image' width='80' height='81' border='0' /></a>";
$texturl = "<a href='$url' target='_blank'>Larger Image</a>";

echo "<table width='382' border='1' bordercolor='#F8F0F8' bgcolor='#0000FF' class='whiteonbluelink'>
  <tr>
    <th colspan='2' scope='col'><div align='left' class='style3'>$id $url uploaded by $uploader on the $dateuploaded </div></th>
  </tr>
  <tr>
    <td width='93'><span class='style5'>$compurl<br> $texturl</span></td>
    <td width='273'><span class='style5'>$description</span></td>
  </tr>
  <tr>
    <td colspan='2'><div align='center' class='style5'>Category: $category </div></td>
  </tr>
</table> <br>";
  }

 

How could I incorporate your code into $compurl so that the javascript close window link is in the same window as the newly opened image.

 

Sorry for my ignorance but didnt someone once say that the path to wisdom starts with the words I dont  know, maybe it was me.

 

Thank you again

 

Christian

 

Is the new url just a link to the image?

Meaning "url_etc/image-name.jpg"

 

If it's an image like that, then you need to output the image in a new page, not a link to the image itself.

Make the larger image open in a random php page that will host all those image.

 

Once you have that page, you just put the code suggested in it, and it doesn't even need to change, since it's just closing that window.

 

So the new page say "images.php"

Would be something like:

 

<?php

 

// Use GET to grab image information

$image = $_GET['Insert-Image-URL-Here'];

echo $image;

echo "<br /> <a href='javascript:window.close()'>Close Window</a>";

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.