I have created a simple gallery program that automatically creates links to each gallery using the readdir() function. The problem I am having is that when a user accesses any subcategory, the menu resets itself. Here is the script I am using to write the categories in:

<? 
if ($ctg == "film"){
$itPath = 'galleries/film/';
	if ($handle = opendir($itPath)) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != ".." && ($file != 'thumbs')) {
	   $ctg = 'film';
	echo "<A class=gallerySub href=gallery.php?cat=film&subC=$file>$file\n<BR>";
          // echo "$file\n<BR>";
       }
   }
   closedir($handle);
   echo '<BR>';
};
	}
		?>

So when a user actually selects a subcategory, they are linked to 'gallery.php?cat=film&subC=$file'. When gallery.php opens, the variable $cat seems to be resetting every time. Does anyone know a way around this?

I'm fairly new to PHP, so be gentle 😃

You can see the error for yourself at http://www.mattsander.com/bai/gallery.php (only the category 'film' and the subcategory 'decoys' is filled in). Thanks in advance!

    i d i o t

    The moment I read my post I noticed the problem - a simple typo.

    If only I had caught that three hours ago.

    Thanks for your time in any case,

    Matt

      Write a Reply...