\n\n";
// make this part a function
if ($parent_directory != "photos") {
echo "
Home | \n";
echo "Photos | \n";
echo "$parent_directory | \n";
echo "$final_directory
\n\n";
}
else {
echo "
Home | \n";
echo "Photos | \n";
echo "$final_directory
\n\n";
}
echo "
\n\n";
echo "
$heading
\n\n";
//////////////////////////////////////////////////////////////
// BEGINNING OF SECTION THAT CREATES A TABLE OF THUMBNAILS.
// THUMBNAILS ARE IN A DIRECTORY INSIDE OF MAIN PHOTOS
// DIRECTORY CALLED "thumbs"
//////////////////////////////////////////////////////////////
// Fill an array with all items from a directory.
if ($handle = opendir($current_path)) {
while (false !== ($file_name = readdir($handle))) {
$pic_array[] = $file_name;
//echo "$file_name
"; //debug
}
closedir($handle);
}
// Take only the jpgs into a sorted array.
$n=1;
//echo "
"; // for debug:
foreach ($pic_array as $mypic){
$file_ext = strstr($mypic,'.');
if($file_ext == ".jpg" || $file_ext ==".JPG") {
$nice_array[$n] = $mypic;
//echo "nice_array $n is $nice_array[$n]
\n"; //debug
$n = $n+1;
}
}
// Get number of items in array and the remainder when divided by 3
$num_files = count($nice_array);
$num_rows = floor($num_files/3);
$remainder = $num_files%3;
// This is for debugging only.
// echo "\n
";
// echo "Number of files: $num_files
\n";
// echo "Number of full rows: $num_rows
\n";
// echo "Remainder files: $remainder
\n\n";
// echo "\n
";
// foreach ($pic_array as $mypic){
// echo "$mypic
";
// }
// Create a table of thumbnails 3 columns wide
echo "
\n\n";
// Two FOR loops take care of the complete rows
for ($i=1; $i<=$num_rows; $i++) {
echo "\n";
for ($j=1; $j<=3; $j++) {
echo "  | \n";
$k=$k+1;
}
echo "
\n";
}
// Use this logic to take care of remainder files
if ($remainder !== 0){
if ($remainder == 2) {
echo "\n";
for ($j=1; $j<=2; $j++) {
echo "  | \n";
$k=$k+1;
}
echo "* | \n";
echo "
\n";
} elseif ($remainder == 1) {
echo "\n";
echo "  | \n";
$k=$k+1;
for ($j=1; $j<=2; $j++) {
echo "* | \n";
}
echo "
\n\n";
} else warn("Remainder value doesn't make sense.\n");
}
echo "\n
\n\n";
///////////////////////////////////////////////////////
// END OF SECTION THAT CREATES A TABLE OF THUMBNAILS
///////////////////////////////////////////////////////
echo "\n\n";
echo "
\n\n";
echo "
\n\n";
// make this part a function
if ($parent_directory != "photos") {
echo "
\n";
echo "Home | \n";
echo "Photos | \n";
echo "$parent_directory | \n";
echo "$final_directory\n";
echo "
\n\n";
}
else {
echo "
\n";
echo "Home | \n";
echo "Photos | \n";
echo "$final_directory\n";
echo "
\n\n";
}
echo "
This page was created using this PHP script.