Jump to content

Recommended Posts

I thought I'd posted it all! My mistake!

 

This is ALL the PHP.

 

        <?php

	/* settings */
	$image_dir = 'gallery/';
	$per_column = 6;


	/* step one:  read directory, make array of files */
	if ($handle = opendir($image_dir)) {
		while (false !== ($file = readdir($handle))) 
		{
			if ($file != '.' && $file != '..') 
			{
				if(strstr($file,'-thumb'))
				{
					$files[] = $file;
				}
			}
		}
		closedir($handle);
	}

	/* step two: loop through, format gallery */
	if(count($file))
	{
		foreach($files as $file)
		{
			$count++;
			echo '<a class="photo-link" rel="one-big-group" target="_blank" href="',$image_dir,str_replace('-thumb','',$file),'"><img src="',$image_dir,$file,'" target="_blank" width="100" height="100" /></a>';
			if($count % $per_column == 0) { echo '<div class="clear"></div>'; }
		}
	}
	else
	{
		echo '';
	}

?>

You are a legend!

 

Thank you! Worked perfectly without fuss!

 

Can I ask how you knew that? Is it simple?

 

I want to learn PHP, but I'm really stupid - I promise to try though!

 

Thanks, once again, fantastic person!

 

You can't increment a value that doesn't exist.  Your original $count didn't contain anything.  The function count and your manually created variable $count are two different things.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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