Jump to content


Photo

Photo Gallery


  • Please log in to reply
4 replies to this topic

#1 ShiVer

ShiVer
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationJoMo

Posted 03 July 2006 - 08:52 PM

Okay, I'm creating a photo gallery, here's how I would like it to work:

The user updating the gallery simply connects to the FTP and uploads a folder with all the images in it. The folder name must be what they want the title of the album to be. And the first image in the folder alphabetically must be the image that they want to be the preview. Everyone follow? Good...

Well, I have a loop that reads the "Albums" directory which is the one they drop they're folder into. It finds all the folders in that folder and prints them with the Folder names as titles. I also have a loop that reads all the images in each individual albums and displays the image for that "Preview". The only problem is I don't know how to make so that it Only reads the FIRST image of the album for the preview rather than pulling every image and showing the Album folders repeatedly for each image. I'll leave my code for those you understand, any help would be great, you could modify my existing or write a better way. Thanks to anyone to helps in advance. If you have any questions feel free to ask, thanks,

- Ryan

<?php
$od = opendir("albums");
while($dir = readdir($od)) {
	if($dir[0] == '.') {
		continue;
	}
	$nd = opendir("albums/".$dir);
	while($img = readdir($nd)) {
		if($img[0] == '.') {
			continue;
		}
		echo '
		<table cellpadding="2" cellspacing="1" border="0">
		  <tr>
			<td>'.$dir.'</td>
		  </tr>
		  <tr>
			<td><a href="index.php"><img src="albums/'.$dir.'/'.$img.'" width="100" height="100" border="0" /></a></td>
		  </tr>
		</table>
		';
	}
}
?>


#2 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 03 July 2006 - 11:33 PM

I don't completly understand you code, but noticed that you are skipping the '.' dir. Should you be skipping the '..' dir also?

Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#3 ShiVer

ShiVer
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationJoMo

Posted 04 July 2006 - 10:04 AM

That's observant but no actually, $img[0] simply contains the first character of each value... so the first character of . and .. matches, therefore it doesn't show.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 July 2006 - 10:16 AM

$dir="directoryname/";
$dr=opendir($dir); // correct method for windows.

closedir($dir);// correct way to close directory.

example ok

<?php
$dir = "/etc/php5/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
  if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== false) {
          echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
      }
      closedir($dh);
  }
}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 ShiVer

ShiVer
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationJoMo

Posted 06 July 2006 - 04:43 PM

I still can't seem to figure this out, I've a number of different things, and each has it's own unique problem. Any ideas from anyone?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users