Here's the navigation:
1st page: Select Product (goes to the next page with the GET I think)
2nd Page: Select Category
this page is created by a gallery script which loops through directories based off the prodID and the catID which is selected.
I used your code suggestion above to tell the gallery script to display thumbnails from the directory prodID/recent/ if no cat had been selected.
3rd page: Select Layout
this displays the layout with the background selected from the previous page.
If there was a category selected it works perfectly and posts the information to the next page for the designer...however, if the category images are displayed from the directory "recent", the images don't show up as the background, and it doesn't post to the next page.
Here's the gallery script for reference:
PHP Code:
<?php
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
// open the directory
$dir = opendir( $pathToImages );
// loop through it, looking for any/all JPG files:
while (false !== ($fname = readdir( $dir ))) {
// parse path for the extension
$info = pathinfo($pathToImages . $fname);
// continue only if this is a JPEG image
if ( strtolower($info['extension']) == 'jpg' )
{
// echo "Creating thumbnail for {$fname} <br />";
// load image and get image size
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
// close the directory
closedir( $dir );
}
// call createThumb function and pass to it as parameters the path
// to the directory that contains images, the path to the directory
// in which thumbnails will be placed and the thumbnail's width.
// We are assuming that the path will be a relative path working
// both in the filesystem, and through the web for links
$cat1 = $_POST['cat1'];
if (isSet($_POST['cat1'])){
createThumbs("prodimages/{$rs['pId']}/{$cat1}/","gallery/{$rs['pId']}/{$cat1}/",200);
}
else {
createThumbs("prodimages/{$rs['pId']}/recent/","gallery/{$rs['pId']}/recent/",200);
}
?>
<?php
function createGallery( $pathToImages, $pathToThumbs )
{
$output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">";
$output .= "<tr>";
// open the directory
$dir = opendir( $pathToThumbs );
$counter = 0;
// loop through the directory
while (false !== ($fname = readdir($dir)))
{
// strip the . and .. entries out
if ($fname != '.' && $fname != '..')
{
$output .= "<td valign=\"middle\" align=\"center\"><input name=\"optn0\" type=\"radio\" class=\"radio\" id=\"{$fname}\" onclick=\"updateoptimage(0,2,0,1);updateprice0();\" value=\"{$fname}\" />";
$output .= "<input type=\"image\" src=\"{$pathToThumbs}{$fname}\" alt=\"{$fname}\" id=\"img{$fname}\" border=\"0\" style=\"cursor:pointer\" onclick=\"document.getElementById('{$fname}').checked=true;\" />";
$output .= "</td>";
value=\"/select_category.php\" />";
$counter += 1;
if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; }
}
}
// close the directory
closedir( $dir );
$output .= "</tr>";
$output .= "</table>";
// open the file
$fhandle = fopen( "gallery.html", "w" );
// write the contents of the $output variable to the file
fwrite( $fhandle, $output );
// close the file
fclose( $fhandle );
}
// call createGallery function and pass to it as parameters the path
// to the directory that contains images and the path to the directory
// in which thumbnails will be placed. We are assuming that
// the path will be a relative path working
// both in the filesystem, and through the web for links
$cat1 = $_POST['cat1'];
if (isSet($_POST['cat1'])){
createGallery("prodimages/{$rs['pId']}/{$cat1}/","gallery/{$rs['pId']}/{$cat1}/");
}else {
createGallery("prodimages/{$rs['pId']}/recent/","gallery/{$rs['pId']}/recent/",200);
}
?>