Page 1 of 1

PHP Photo Gallery

Posted: Fri Jan 16, 2004 12:23 pm
by maboroshi
Hello I have a question regarding my photo gallery script

I have 20 thumbnails on a page when I click on one it goes to a larger version of that photo that is in the directory I would like the photo when clicked to go to an html or php page instead to display the photo

Anyhelp is always appreciated here is the code

Sorry about the mess

Code: Select all

<?php 
  $a = 0; 
  $new_tr = 0; 
  $filepath = "thumbnails"; 
  $url_path = "images2"; 
  $dir = dir($filepath); 
  $start=0; 
  $stop=22; 

if(!empty($_GET&#1111;'start']) && !empty($_GET&#1111;'stop'])) &#123; 
   $start=intval($_GET&#1111;'start']); 
   $stop=intval($_GET&#1111;'stop']); 
&#125; 

  echo "<table width="640" border="0" cellpadding="1" cellspacing="1">"; 

  while($entry=$dir->read()) &#123; 
   if($a>=$start && $a<$stop) &#123; // $a<$stop because from 0-19 you have 20 pictures 
      if($entry != "." && $entry != "..") &#123; 

           if (!($new_tr%5)) &#123;echo "<tr>";&#125; 
?> 
  <td align="center" valign="top"> 
  <a href="<?php echo "$url_path/$entry/" ?>"> 
 
  <img src="<?php echo "$filepath/$entry"; ?>" alt="<?php echo $entry; ?>" border="1" class="imageborder"></a> 
  </td>
Thanks in advance

There is more to the script but I don't believe it is nessacary it is just the

next previous links

Posted: Fri Jan 16, 2004 1:11 pm
by ilovetoast
Am I understanding you correct--

You want the larger photo to open in a new window when the user clicks on the thumbnail?

If that's all you're after just switch the href from $url_path/$entry/ to a php page. Pass the desired image as a parameter.

Something like:

Code: Select all

<a href="new_page_name.php?image=<?php echo urlencode($entry); ?>" target="_new">
The new page would need a line of code to display the image spceified. You could get fancy and specify a javascript as the link if you want to set characteristics for the new window.

peace

Hey Thanks

Posted: Fri Jan 16, 2004 1:41 pm
by maboroshi
Hey Thanks for the reply but thats not what I am looking for

what I want is the window stays the same but instead of opening just the jpeg it opens an html or php page with the image that was clicked in it

basically what the script does right now is it displays rows and columns of images read from a directory when you click on the image it goes to a larger jpeg file of that image that is in another directory

I was playing around with $PHP_SELF a bit but I could not figure it out

Any help

is appreciated

Hey I think your right

Posted: Fri Jan 16, 2004 1:47 pm
by maboroshi
Hey I think your code will actually work

cool what do I pass the html or php page to display the image

thanks cool

cheers

Andrew

Posted: Fri Jan 16, 2004 3:19 pm
by ilovetoast
Put this (at least) in the new page:

Code: Select all

<?php

	$url_path		= "images2";

?>
And somewhere after that put (at least) this:

Code: Select all

<img src="<?php echo "$url_path/" . $_GET&#1111;'image']; ?>">
peace

Cheers

Posted: Fri Jan 16, 2004 4:49 pm
by maboroshi
Hey Thank you I have it working now

Cheers

Andrew