Hello,
I'm trying to build a 5 column table of divs containing images from a directory and I don't understand why there is always 2 images missing from the output. The correct number of divs show up but when I view the html output, the image name is not getting picked up from the loop for the first 2 divs. If I echo the $imgarr[$i] in the foreach loop I get all of the images, but when the function goes into the for loop it skips 2 images.
function display_photos()
{
$propertyaddress = $_GET['pa'];
$userfolder = $_SESSION['valid_user'];
$dir = 'members/' . $userfolder . '/' . $propertyaddress . '/';
$files = scandir($dir);
$i = 0;
foreach($files as $value) {
// check for image files
if(valid_image_file($value))
// build image array
$imgarr[$i] = $value;
$i++;
}
$count = count($imgarr);
for($j = 0; $j < $count; $j++) {
if($j == 0 || $j%5 == 0)
// echo '<div class="lastrowcol"><img src="' . $dir . $imgarr[$j] . '" width="100" height="100" /></div>';
// else
// echo '<div class="floatright"><img src="' . $dir . $imgarr[$j] . '" width="100" /></div>';
echo '<div class="lastrowcol">' . $imgarr[$j] . '</div>';
else
echo '<div class="floatright">' . $imgarr[$j] . '</div>';
}
}
Thanks for any help with this,
Jason