Jump to content

[SOLVED] Problems with 'Photo Gallery'


phper100001

Recommended Posts

I've been trying to make a very simple photo gallery where the user selects a gallery from a drop-down menu and clicks view. The gallery is supposed to load and display 3 rows of 3 images per page as well as a next and previous button. The drop down menu links to a database which contains the directory the images are located in. For some reason my gallery won't stop when all the files in the directory have been displayed. It also only displays 8 images. (2 rows of 3 and 1 of 2). The menu and image handling works but it isn't looping how I intended. To be perfectly honest I don't know alot about PHP programming and this is probably literred with mistakes.

$Dir = $_GET['Dir'];
$Dir = str_replace(" ", "", $Dir);
$Read = opendir($Dir);
if (!isset($_GET['photoid'])){
	$photoid = "1";
} else {
$photoid = $_GET['photoid'];
}	

$imageinrow = 0;
?>
<table align="center">
<?		
//List files in images directory
while (($file = readdir($Read)) !== false && $rows < 3)
  {
  	$imageinrow = 0;
  	echo "<tr>";
	while (($file = readdir($Read)) !==false &&	$imageinrow < 3) {
?>
		<td width="145" align="center">
			<a href="<? echo $Dir; ?>/image<? echo $photoid; ?>.jpg">
			<img width="135" src="<? echo $Dir; ?>/image<? echo $photoid; ?>.jpg" />
			</a>
		</td>	
<?	
			$photoid++;
			$imageinrow++;	
	}	
			$rows++;
	echo "</tr>";		
  }
  echo "</table>";
  closedir($Read);

Link to comment
https://forums.phpfreaks.com/topic/148665-solved-problems-with-photo-gallery/
Share on other sites

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.