Linking issue/current directory not fully showing

Hey everyone,

So I thought I would be able to figure this out, but for some reason, I’m having trouble figuring out as to why the full path of folders/directories is not showing.

This is what is should look like:

…and this is what I get when I have sub-folders/directories within another main directory

I want the “Existent Categories” list to show on the page after I click on one of the “Category” links. So that when I’m on that page, a list of “current” directories within that folder/directory displays. Like it shows on the “Existent Categories” image. I tried to explain that as simply as I could. Sorry for the confusion. Here are the files that make up this application.

Category.php

<?php

include("system_header.php");

$category_title = trim(strip_tags($_GET['cat_url_string']));

$category_display_title = str_replace('_', ' ', $category_title);
$category_display_title = str_replace('-', ' ', $category_title);
$category_display_title = trim($category_display_title, '-');

if(!is_dir('files/'.urldecode($category_title))){
	include("404.php");
	exit;
}



// test the files to be uploaded, before inserting in DB
$upload_errors = '';
// note that INTERNET EXPLORER (8) detects certain type as "image/pjpeg" !!!
$acceptable_file_types = array("image/jpeg","image/pjpeg","image/gif","image/png","image/bmp");
// max photo size in kb (10MB = 10000);
$max_photo_size = 10000; 


$working_directory = "files/".$category_title;


// test uploads for size and format
if($is_admin and isset($_FILES["photo_box"]) and $_FILES["photo_box"]["name"]!=''){
		
	if(!in_array($_FILES["photo_box"]["type"],$acceptable_file_types)){
		$upload_errors .= "Photo should be jpg, gif or png; ";
	}
	if($_FILES["photo_box"]["size"]/1024 > $max_photo_size){
		$upload_errors .= "Photo is too large (".size_convert($_FILES["photo_box"]["size"])."), maximum size is ".($max_photo_size/1000)."MB; ";
	}
	
	
	// final will be a string like "landscape-with-mountain"
	$photo_name = pathinfo($_FILES["photo_box"]["name"], PATHINFO_FILENAME);
	$photo_name = strtolower($photo_name);
	$photo_name = string_to_file_name($photo_name);

	// make sure the photo file is not duplicate
	if(file_exists($working_directory."/".$photo_name.".jpg")){
		$upload_errors .= "File (".$photo_name.".jpg) already exists in this category (".$category_display_title."); ";
	}
	
	// upload the file and re-size it
	if($upload_errors==''){
		
		// append this prefix, otherwise they will have same name
		$temporary_file = "temporary_".$_FILES["photo_box"]["name"];
		
		// move original file into a  working directory
		move_uploaded_file($_FILES["photo_box"]["tmp_name"], $working_directory."/".$temporary_file);
		
		// save and scale down source image
		if($imagemagick_installed){
			resize_in_limits($working_directory."/".$temporary_file, $working_directory."/".$photo_name.".jpg", 2000, 2000);
		} else {
			gd_resize_in_limits($working_directory."/".$temporary_file, $working_directory."/".$photo_name.".jpg", 2000, 2000);
		}
		
		// !!! delete original file here, later the uploaded file and main image can have same name, avoid removing main file
		unlink($working_directory."/".$temporary_file);
		
		// save and scale down the "display" image
		if($imagemagick_installed){
			resize_in_limits($working_directory."/".$photo_name.".jpg", $working_directory."/".$photo_name."_small.jpg", $settings_photo_width, $settings_photo_height);
		} else {
			gd_resize_in_limits($working_directory."/".$photo_name.".jpg", $working_directory."/".$photo_name."_small.jpg", $settings_photo_width, $settings_photo_height);
		}
		
		// save and CROP the thumb image
		if($imagemagick_installed){
			crop_image($working_directory."/".$photo_name.".jpg", $working_directory."/".$photo_name."_thumb.jpg", $settings_thumbnail_width, $settings_thumbnail_height);
		} else {
			gd_crop_image($working_directory."/".$photo_name.".jpg", $working_directory."/".$photo_name."_thumb.jpg", $settings_thumbnail_width, $settings_thumbnail_height);
		}
		
		// if category has no thumb, then copy this one
		if(!file_exists("files/".$category_title."/thumbnail.jpg")){
			copy($working_directory."/".$photo_name."_thumb.jpg", "files/".$category_title."/thumbnail.jpg");
		}
		
		// refresh page
		header("Location: ?message=Uploaded photo: ".$category_title."/".$photo_name.".jpg&message_type=success");
		exit;
		
	} else {
		header("Location: ?message=".$upload_errors."&message_type=error");
		exit;
	}
	
}




$page_title = ucwords($category_display_title);
$page_description = ucwords($category_display_title)." | Photo Gallery";

?>
<?php include("header.php");?>


<script type="text/javascript"><!--

// selected photo for upload
function selected_photo_file(){
	
	if(document.getElementById('photo_box').value != ''){
		file_extension = document.getElementById('photo_box').value.split('.').pop().toLowerCase();
		if(file_extension != 'jpg' && file_extension != 'jpeg' && file_extension != 'gif' && file_extension != 'png' && file_extension != 'bmp'){
			alert("Sorry, "+file_extension+" files cannot be uploaded, accepted formats are: jpg, gif or png");
			return false;
		} else {
			document.getElementById('photo_form').style.display = 'none';
			document.getElementById('loading_info_div').style.display = 'inline-block';
			document.getElementById('photo_form').submit();
		}
	}
	
}




function show_large_gallery(){
	document.getElementById('large_gallery').style.display = '';
	document.getElementById('thumbnails_strip').style.display = '';
	gallery_is_visible = true;
	// hide scroll bars
	document.body.style.overflowX = 'hidden';
	document.body.style.overflowY = 'hidden';
	
}

function hide_large_gallery(){
	document.getElementById('large_gallery').style.display = 'none';
	document.getElementById('thumbnails_strip').style.display = 'none';
	gallery_is_visible = false;
	// allow scroll bars
	document.body.style.overflowX = '';
	document.body.style.overflowY = '';
	
}



var images_array = new Array();
var images_url_array = new Array();

<?php foreach($categories_array[$category_title] as $photo_file){ ?>
images_array.push('<?php echo addslashes($photo_file);?>');
images_url_array.push('<?php echo rawurlencode($photo_file);?>');
<?php } ?>



document.onkeyup = KeyCheck;       
function KeyCheck(e){
	var KeyID = (window.event) ? event.keyCode : e.keyCode;
	
	// left key pressed
	if(KeyID == 37 && gallery_is_visible){ 
		switch_large_image(active_large_image-1);
	}

	// right key pressed
	if(KeyID == 39 && gallery_is_visible){ 
		switch_large_image(active_large_image+1);
	}
	
	// ESC key pressed
	if(KeyID == 27 && gallery_is_visible){ 
		hide_large_gallery();
	}
}


// active image will represent the KEY not the value, it will probably go to 0 to 5
active_large_image = 0;


//
gallery_is_visible = false;
function switch_large_image(image_key){
	// if requested image is larger than last image, then show first image (loop trough images on keypress)
	if(image_key>=images_array.length) {
		image_key = 0;
	}
	// if requested image is smaller than first image, then show last image (loop trough images on keypress)
	if(image_key<0) {
		image_key = images_array.length-1;
	}
	// disable border from current image
	document.getElementById('strip_image_'+active_large_image).style.borderColor = '#282828';
	// set border on new active image
	document.getElementById('strip_image_'+image_key).style.borderColor = '#0099FF';
	
	// change the overlay title on the image
	document.getElementById('large_image_title').innerHTML = images_array[image_key].replace(/-/g," ");
	
	// switch the large image
	document.getElementById('large_image').src = '<?php echo $gallery_url;?>/<?php echo rawurlencode($category_title);?>/'+images_url_array[image_key]+'_small.jpg';
	
	// show the large image and strip line
	show_large_gallery();
	// mark this image as active
	active_large_image = image_key;
	
	
	// alert(window.innerWidth+'x'+window.innerHeight);
	
	// alert(document.getElementById('thumbnails_container').offsetWidth);
	
	center_thumbnails_container();
	
}

// will also be fired on window resize
function center_thumbnails_container(){
	
	thumbnails_width = document.getElementById('thumbnails_container').offsetWidth;
	
	// active_image_offset = document.getElementById('strip_image_'+images_array[active_large_image]).offsetLeft;
	active_image_offset = active_large_image*90;
	
	// the limit on left side, (maximum position of the thumbnails)
	thumbnails_left_limit = 0;
	
	// the limit on right side, (minimum position of the thumbnails)
	thumbnails_right_limit = window.innerWidth-thumbnails_width-20;
	
	new_thumbnails_position = Math.round((window.innerWidth/2)-active_image_offset)-59;
	
	// limit the left margin position
	if(new_thumbnails_position>thumbnails_left_limit){
		new_thumbnails_position = thumbnails_left_limit;
	}
	
	// limit the right margin position
	if(new_thumbnails_position<thumbnails_right_limit){
		new_thumbnails_position = thumbnails_right_limit;
	}
	
	// if window is larger than thumbs strip, then position at default value (all above calculations canceled)
	if(window.innerWidth>=thumbnails_width){
		new_thumbnails_position = 0;
	}

	
	document.getElementById('thumbnails_container').style.marginLeft = new_thumbnails_position+'px';
	
	// console.log('Left margin:	'+thumbnails_left_limit);
	// console.log('Right margin:	'+thumbnails_right_limit);
	// console.log('New position:	'+new_thumbnails_position);
	
	// limit the height of the image to fit in that area, not needed for most computers, useful for cell phones
	document.getElementById('large_image').style.maxWidth = window.innerWidth-12+'px';
	document.getElementById('large_image').style.maxHeight = window.innerHeight-document.getElementById('thumbnails_strip').offsetHeight-12+'px';
	
}


//--></script>




<h1 style="text-transform:capitalize;"><?php echo htmlentities($category_display_title, ENT_QUOTES, "UTF-8");?></h1>

<p class="breadcrumb"><a href="admin.php">home</a> &gt; <a href="<?php echo $gallery_url;?>">gallery</a> &gt; <?php echo htmlentities($category_display_title , ENT_QUOTES, "UTF-8");?></p>

<?php if(count($categories_array[$category_title])<=0){?>
<p>There are no photos under <strong><?php echo htmlentities($category_display_title , ENT_QUOTES, "UTF-8");?></strong>.</p>
<?php } ?>


<?php if($is_admin){?>
    <form name="photo_form" id="photo_form" enctype="multipart/form-data" method="post" action="" style="display:none; border:1px solid #CCC; padding:10px; background-color:#F5F5F5; margin-bottom:10px;">
    
        <span id="photo_box_span">
        <input type="file" name="photo_box" id="photo_box" accept="image/*" onChange="selected_photo_file();" style="border:none;"/>
        </span>
        
       
        <img src="<?php echo $gallery_url;?>/layout/delete_16x16.gif" width="16" height="16" style="float:right; cursor:pointer;" onmouseup="document.getElementById('photo_form').style.display='none'; document.getElementById('photo_upload_button').style.display='';" alt="close upload form" title="close upload form" />
    
    </form>
    
    <span id="loading_info_div" style="background-image:url('<?php echo $gallery_url;?>/layout/loading_20x20.gif'); background-repeat:no-repeat; padding-left:24px; padding-top:3px; padding-bottom:2px; margin-top:10px; color:#EA0000; display:none;">Please wait, photo is uploading</span>
    
    <!--
    <a href="<?php echo $gallery_url;?>/upload?category_title=<?php echo urlencode($category_title);?>" class="liquid_button">Upload photos</a>
	-->
    
    <a id="photo_upload_button" href="JavaScript:void(0);" onmouseup="document.getElementById('photo_form').style.display=''; document.getElementById('photo_upload_button').style.display='none';" class="liquid_button" style="padding-left:10px; padding-right:10px; margin-right:5px;">Upload photos</a>
    
    <a id="photos_edit_button" href="<?php echo $gallery_url;?>/<?php echo rawurlencode($category_title);?>/edit-photos" class="liquid_button" style="padding-left:10px; padding-right:10px;">Edit photos</a>
    
    
<?php } // if is admin ?>



<?php if(count($categories_array[$category_title])>0){?>
	<div style="display:block; margin-top:10px;">
    <?php $photo_counter = 0;?>
	<?php foreach($categories_array[$category_title] as $photo_file){ ?>
	<?php if(is_dir($gallery_url)){ ?>
    <img src="<?php echo $gallery_url."/".rawurlencode($category_title)."/".rawurlencode($photo_file)."_thumb.jpg" ;?>" style="padding:5px; border:1px solid #CCC; margin-top:5px; margin-right:5px; cursor:pointer;" onclick="switch_large_image(<?php echo $photo_counter;?>);" alt="<?php echo htmlentities(ucwords(str_replace('-', ' ', $photo_file)));?>" title="<?php echo htmlentities($photo_file, ENT_QUOTES, "UTF-8");?>" />
    <?php $photo_counter++;?>
    <?php }elseif(!is_dir($gallery_url)){?>
	
	<table width="100%" border="0" cellspacing="0" cellpadding="10">
    
    <?php
	if(!isset($row_color) or $row_color=='#F7F7F7'){
		$row_color = '#F1F1F1';
	} else {
		$row_color = '#F7F7F7';
	}
	?>
	
	<tr>
  
    <td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>
    
    <td width="300" height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>">
    
    
    
    <input name="button2" type="button" class="cancel_button_30" id="button2" style="float:right;" onmouseup="if(confirm('Delete category <?php echo htmlentities(addslashes($photo_category), ENT_QUOTES, "UTF-8");?> ? \nIt contains <?php echo count($photos_array);?> photos')){window.location='?key=<?php echo md5($_SESSION['session_secret'].$photo_category);?>&category_to_delete=<?php echo rawurlencode($photo_category);?>';}"  />
    
    <input name="button3" type="button" class="button_110" id="button3" value="Rename" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/admin-category-edit?category_title=<?php echo rawurlencode($photo_category);?>';"/>
    
    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>
    
    </td>
    
    </tr>

    <?php } ?>
    
    </table>
	
	<?php } ?>
    <?php } ?>
    </div>





<?php // the top: should be minus half of the thumbs height; minus half the padding around thumbs ?>
<table id="large_gallery" width="100%" style="height:100%; position:fixed; top:-<?php echo round($settings_thumbnail_height/4)+10;?>px; left:0px; display:none; text-align:center; margin:auto;" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" height="100%" align="center" valign="middle" bgcolor="#000000" style="overflow:hidden;" onclick="do_with_delay='close_gallery'; setTimeout('if(do_with_delay==\'switch_photo\'){switch_large_image(active_large_image+1)} else { hide_large_gallery();}', 20);">
    
    <input name="" type="button" class="cancel_button_30" style="position:absolute; top:50px; right:10px;" title="close the gallery" />

	<span style="display:inline-block; width:auto; white-space:nowrap;">
    
        <img id="large_image" src="" style="cursor:pointer; padding:5px; background-color:#FFFFFF; border:1px solid #CCCCCC; margin:auto; position:relative; bottom:-14px;" onclick="setTimeout('do_with_delay=\'switch_photo\'', 10);" alt="" /> 
        
        <?php // this overlay title has a smaller width (fitting image border) by placing the transparent background ~10px to the right then moving the complete title to the left ;?>
                
        <span id="large_image_title" style="color:#FFFFFF; display:block; width:100%; line-height:1em; padding-top:9px; height:20px; position:relative; top:-21px;left:-6px; background-image:url('<?php echo $gallery_url;?>/layout/transparent_bg.png'); background-repeat:no-repeat; background-position:12px 0px; text-transform:capitalize;"></span>
        
	</span>
    
    <?php 
	// the above complicated thing with do_with_delay (close_gallery/switch_photo) will allow to make a difference between clicking the photo 
	// or its parent element; then decide if it should show next photo (photo click) or close gallery (background click)
	?>
    
    </td>
  </tr>
</table>


<!-- thumbnails strip -->
<div id="thumbnails_strip" style="position:fixed; height:<?php echo round(($settings_thumbnail_height/2)+10);?>px; bottom:0px; left:0px; width:100%; background-color:#282828; border-top:1px solid #555555; text-align:center; padding:5px; display:none;">
    
    <span id="thumbnails_container" style="display:inline-block; white-space:nowrap; width:<?php echo count($categories_array[$category_title])*90;?>px; height:<?php echo round(($settings_thumbnail_height/2)+10);?>px; overflow:hidden;">
    <?php $photo_counter = 0;?>
    <?php foreach($categories_array[$category_title] as $photo_file){ ?>

    <img id="strip_image_<?php echo $photo_counter;?>" src="<?php echo $gallery_url;?>/<?php echo rawurlencode($category_title);?>/<?php echo rawurlencode($photo_file);?>_thumb.jpg" border="0" alt="" style="display:inline-block; float:left; cursor:pointer; border:5px solid #282828;" onmouseup="switch_large_image(<?php echo $photo_counter;?>);" width="<?php echo round($settings_thumbnail_width/2);?>" height="<?php echo round($settings_thumbnail_height/2);?>" />
	
    <?php $photo_counter++;?>
	<?php } ?>
    </span>
</div><!-- end of thumbnails_strip -->   

<script type="text/javascript"><!--
window.onresize = function(){ center_thumbnails_container();}
--></script>


<?php include("footer.php");?>

admin_categories.php

<?php

include("system_header.php");

admin_only();

$Category_Select = $_POST['Category_Select'];

// category doesn't exist
if(!is_dir("files/".$old_category_title)){
	header("Location: ".$gallery_url."/admin-categories?message=That category does not exist&message_type=error");
	exit;
}
// does category box have value
if(isset($_POST['category_title_box']) and $_POST['category_title_box']!=''){

	// was Category_Select selected
	if(isset($_POST['Category_Select'])){
		
		//yes, create folder within that folder
		$new_category_title = string_to_file_name($_POST['category_title_box']);
		
		mkdir('files/'.$Category_Select."/".$new_category_title);
		header("Location: ".$gallery_url."/admin-categories?message=Sub Category added&message_type=success");
		exit();
		
	}
	// add new category
	elseif(isset($_POST['category_title_box']) and $_POST['category_title_box']!=''){
	
	$new_category_title = string_to_file_name($_POST['category_title_box']);
	
	mkdir('files/'.$new_category_title);
	
	header("Location: ".$gallery_url."/admin-categories?message=Category added&message_type=success");
	exit;	
	}
}


// !!! delete category and all photos inside !!!
if(isset($_GET['category_to_delete']) and $_GET['category_to_delete']!='' and $_GET['key']==md5($_SESSION['session_secret'].$_GET['category_to_delete'])){
	rmdir_r('files/'.strip_tags(trim($_GET['category_to_delete'])));
	
	header("Location: ".$gallery_url."/admin-categories?message=Category ".$_GET['category_to_delete']." deleted&message_type=success");
	exit;
}

?>
<?php include("header.php");?>
<h1>Manage Categories</h1>
<p class="breadcrumb"><a href="admin.php">home</a> &gt; <a href="<?php echo $gallery_url;?>">gallery</a> &gt; <a href="<?php echo $gallery_url;?>/admin">admin</a> &gt; categories</p>

<?php if(count($categories_array)<=0){?>
<p>There are no photo categories, create one or more categories before uploading photos</p>
<?php } ?>


<form id="form1" name="form1" method="post" action="" style="margin:0px;">
        
    <label for="category_title_box">New Category Title</label><br />
		  <input name="category_title_box" type="text" id="category_title_box" size="20" />
          <br />
	  <br />
		   Select a current Category: <?php echo $Category_Select. "<br/>"; ?>
		   <select id="Category_Select" name="Category_Select" height="27px">
			<option value="" selected="selected">-----</option>
				<?php 
					foreach(glob(dirname(__FILE__) . '/files/*') as $filename){
						$filename = basename($filename);
						echo "<option value='" . $filename . "'>".$filename."</option>";
					}
				?>
		   </select>
		   <br />

          <input name="button" type="submit" class="button_190" id="button" value="Add category" style="margin-top:10px;" />
</form>

<script type="text/javascript">
document.getElementById('category_title_box').focus();
</script>

  
<?php if(count($categories_array)>0){?>

	<h2 style="margin-top:30px;">Existent categories</h2>
	
    	
    <table width="100%" border="0" cellspacing="0" cellpadding="10">
	<?php foreach($categories_array as $photo_category=>$photos_array){?>
    
    <?php
	if(!isset($row_color) or $row_color=='#F7F7F7'){
		$row_color = '#F1F1F1';
	} else {
		$row_color = '#F7F7F7';
	}
	?>
	
	<tr>
  
    <td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>
    
    <td width="300" height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>">
    
    
    
    <input name="button2" type="button" class="cancel_button_30" id="button2" style="float:right;" onmouseup="if(confirm('Delete category <?php echo htmlentities(addslashes($photo_category), ENT_QUOTES, "UTF-8");?> ? \nIt contains <?php echo count($photos_array);?> photos')){window.location='?key=<?php echo md5($_SESSION['session_secret'].$photo_category);?>&category_to_delete=<?php echo rawurlencode($photo_category);?>';}"  />
    
    <input name="button3" type="button" class="button_110" id="button3" value="Rename" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/admin-category-edit?category_title=<?php echo rawurlencode($photo_category);?>';"/>
    
    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>
    
    </td>
    
    </tr>

    <?php } ?>
    
    </table>
<?php } ?>

<?php include("footer.php");?>

System_header.php

<?php

error_reporting(6135); 

include("settings.php");

$page_load_start = microtime(true);


if (!isset($_SESSION)) {
	session_start();
}

// this is needed to properly handle the special characters in file names, image resize might fail without this
setlocale(LC_CTYPE, "en_US.UTF-8");

$gallery_domain = str_replace("www.", "", $_SERVER['HTTP_HOST']);

// the gallery_url is the url of the gallery script (the folder), relative to site root, e.g /gallery
$gallery_url  = dirname($_SERVER['SCRIPT_NAME']);
$gallery_url = str_replace($_SERVER['DOCUMENT_ROOT'], '', $gallery_url);

error_reporting(E_ALL ^ E_NOTICE);

include("system_functions.php");

// test if this user is admin or not
$is_admin = false;

if($_SESSION['session_admin'] == md5($_SESSION['session_secret'].$settings_secret)){
	$is_admin = true;
}


// $photo_categories_array = array();
// $total_photos_array = array();

// this will be an array in array, first key is cat, second key is image file: 
// $categories_array['cars']['retro-car']
$categories_array = array();

$timer_1 = microtime(true);

/*
// loop over files directory and read the categories
if ($handle = opendir('files')) {
    while (false !== ($folder = readdir($handle))) {
		if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){
			
			// define this key in the array, it will be blank, store categories as keys
			$categories_array[$folder] = array();

			// $total_photos_array[$folder] = 0;
			
			$files_in_dir = scandir('files/'.$folder);
			foreach($files_in_dir as $file){
				// if file ends in _thumb.jpg
				if(strpos($file, '_thumb.jpg') === strlen($file)-10){
					// $total_photos_array[$folder]++;
					$base_file_name = substr($file, 0,  strlen($file)-10);
					// insert this file in the array of files
					array_push($categories_array[$folder], $base_file_name);
				}
			}
			
		}
    }
    closedir($handle);
}
*/

// loop over files directory and read the categories
$scandir_array = scandir('files');
foreach($scandir_array as $folder){

	if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){
		
		// define this key in the array, it will be blank, store categories as keys
		$categories_array[$folder] = array();

		// $total_photos_array[$folder] = 0;
			
		$files_in_dir = scandir('files/'.$folder);
		foreach($files_in_dir as $file){
			if($file!='.' and $file!='..'){
				
				// if file is not the category thumbnail (thumbnail.jpg) and not _thumb.jpg and not _small.jpg
				if($file != "thumbnail.jpg" and substr($file, strlen($file)-10) != "_small.jpg" and substr($file, strlen($file)-10) != "_thumb.jpg"){
					// $total_photos_array[$folder]++;
					$base_file_name = substr($file, 0,  strlen($file)-4);
					// insert this file in the array of files
					array_push($categories_array[$folder], $base_file_name);
					
					//echo "<br>$base_file_name";
					
				}
			}
		}
		
	}
}



$timer_2 = microtime(true);

// !! if you use wrong sorting parameter it will convert the category string keys into integer
ksort($categories_array);


// test if imagemagick is installed
$imagemagick_installed = false;
@exec("convert -version", $convert_output_array);
if(strpos($convert_output_array[0], "imagemagick")){
	$imagemagick_installed = true;
}


?>

I tried to include all of the files I thought were necessary to help solve this issue. I originally had this application for only main directory folders and have photos within those main folders. I forgot the capability to add folders within main folders. Any advice or direction would be most appreciative :slight_smile: Thank you!

Any chance you could edit down the code to just show the parts that actually deal with displaying the list of categories? It would make it much easier to figure out what’s going on without having to wade through code that seems to deal with uploading images etc.

That said, I’m not entirely sure I understand the question. How does the list of category 2, 3 and 4 relate to the “Wedding” folder? Are they categories inside that folder, so Wedding/category 2, Wedding/category 3 and so on?

On this line (and the line above it):

    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>

where does $photo_category come from? I can’t see it in the code above, but I might have missed it.

The only file that had all the photo manipulation was in the category.php file. I did what I could to take all that out.

The list (category/“main folder” 1, 2, 3 and 4) resemble what I am trying to achieve when I click on a main category that has a sub-folder. Basically, I want to be able to click one of the main categories that has a sub folder within it and list out the sub folders within that category item I have clicked on.

The variable $photo_category comes from the foreach() loop where $categories_array() is put into a new variable which will be stored into $photo_categories, which is then stored into an array of $photos_array.

category.php

<?php

include("system_header.php");

$category_title = trim(strip_tags($_GET['cat_url_string']));

$category_display_title = str_replace('_', ' ', $category_title);
$category_display_title = str_replace('-', ' ', $category_title);
$category_display_title = trim($category_display_title, '-');

if(!is_dir('files/'.urldecode($category_title))){
	include("404.php");
	exit;
}

$working_directory = "files/".$category_title;


$page_title = ucwords($category_display_title);
$page_description = ucwords($category_display_title)." | Photo Gallery";

?>
<?php include("header.php");




<h1 style="text-transform:capitalize;"><?php echo htmlentities($category_display_title, ENT_QUOTES, "UTF-8");?></h1>

<p class="breadcrumb"><a href="admin.php">home</a> &gt; <a href="<?php echo $gallery_url;?>">gallery</a> &gt; <?php echo htmlentities($category_display_title , ENT_QUOTES, "UTF-8");?></p>

<?php if(count($categories_array[$category_title])<=0){?>
<p>There are no photos under <strong><?php echo htmlentities($category_display_title , ENT_QUOTES, "UTF-8");?></strong>.</p>
<?php } ?>


<?php if($is_admin){?>
    <form name="photo_form" id="photo_form" enctype="multipart/form-data" method="post" action="" style="display:none; border:1px solid #CCC; padding:10px; background-color:#F5F5F5; margin-bottom:10px;">
    
        <span id="photo_box_span">
        <input type="file" name="photo_box" id="photo_box" accept="image/*" onChange="selected_photo_file();" style="border:none;"/>
        </span>
        
       
        <img src="<?php echo $gallery_url;?>/layout/delete_16x16.gif" width="16" height="16" style="float:right; cursor:pointer;" onmouseup="document.getElementById('photo_form').style.display='none'; document.getElementById('photo_upload_button').style.display='';" alt="close upload form" title="close upload form" />
    
    </form>
    
    <span id="loading_info_div" style="background-image:url('<?php echo $gallery_url;?>/layout/loading_20x20.gif'); background-repeat:no-repeat; padding-left:24px; padding-top:3px; padding-bottom:2px; margin-top:10px; color:#EA0000; display:none;">Please wait, photo is uploading</span>
    
    <!--
    <a href="<?php echo $gallery_url;?>/upload?category_title=<?php echo urlencode($category_title);?>" class="liquid_button">Upload photos</a>
	-->
    
    <a id="photo_upload_button" href="JavaScript:void(0);" onmouseup="document.getElementById('photo_form').style.display=''; document.getElementById('photo_upload_button').style.display='none';" class="liquid_button" style="padding-left:10px; padding-right:10px; margin-right:5px;">Upload photos</a>
    
    <a id="photos_edit_button" href="<?php echo $gallery_url;?>/<?php echo rawurlencode($category_title);?>/edit-photos" class="liquid_button" style="padding-left:10px; padding-right:10px;">Edit photos</a>
    
    
<?php } // if is admin ?>



<?php if(count($categories_array[$category_title])>0){?>
	<div style="display:block; margin-top:10px;">
    <?php $photo_counter = 0;?>
	<?php foreach($categories_array[$category_title] as $photo_file){ ?>
	<?php if(is_dir($gallery_url)){ ?>
    <img src="<?php echo $gallery_url."/".rawurlencode($category_title)."/".rawurlencode($photo_file)."_thumb.jpg" ;?>" style="padding:5px; border:1px solid #CCC; margin-top:5px; margin-right:5px; cursor:pointer;" onclick="switch_large_image(<?php echo $photo_counter;?>);" alt="<?php echo htmlentities(ucwords(str_replace('-', ' ', $photo_file)));?>" title="<?php echo htmlentities($photo_file, ENT_QUOTES, "UTF-8");?>" />
    <?php $photo_counter++;?>
    <?php }elseif(!is_dir($gallery_url)){?>
	
	<table width="100%" border="0" cellspacing="0" cellpadding="10">
    
    <?php
	if(!isset($row_color) or $row_color=='#F7F7F7'){
		$row_color = '#F1F1F1';
	} else {
		$row_color = '#F7F7F7';
	}
	?>
	
	<tr>
  
    <td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>
    
    <td width="300" height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>">
    
    
    
    <input name="button2" type="button" class="cancel_button_30" id="button2" style="float:right;" onmouseup="if(confirm('Delete category <?php echo htmlentities(addslashes($photo_category), ENT_QUOTES, "UTF-8");?> ? \nIt contains <?php echo count($photos_array);?> photos')){window.location='?key=<?php echo md5($_SESSION['session_secret'].$photo_category);?>&category_to_delete=<?php echo rawurlencode($photo_category);?>';}"  />
    
    <input name="button3" type="button" class="button_110" id="button3" value="Rename" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/admin-category-edit?category_title=<?php echo rawurlencode($photo_category);?>';"/>
    
    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>
    
    </td>
    
    </tr>

    <?php } ?>
    
    </table>
	
	<?php } ?>
    <?php } ?>
    </div>





<?php // the top: should be minus half of the thumbs height; minus half the padding around thumbs ?>
<table id="large_gallery" width="100%" style="height:100%; position:fixed; top:-<?php echo round($settings_thumbnail_height/4)+10;?>px; left:0px; display:none; text-align:center; margin:auto;" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" height="100%" align="center" valign="middle" bgcolor="#000000" style="overflow:hidden;" onclick="do_with_delay='close_gallery'; setTimeout('if(do_with_delay==\'switch_photo\'){switch_large_image(active_large_image+1)} else { hide_large_gallery();}', 20);">
    
    <input name="" type="button" class="cancel_button_30" style="position:absolute; top:50px; right:10px;" title="close the gallery" />

	<span style="display:inline-block; width:auto; white-space:nowrap;">
    
        <img id="large_image" src="" style="cursor:pointer; padding:5px; background-color:#FFFFFF; border:1px solid #CCCCCC; margin:auto; position:relative; bottom:-14px;" onclick="setTimeout('do_with_delay=\'switch_photo\'', 10);" alt="" /> 
        
        <?php // this overlay title has a smaller width (fitting image border) by placing the transparent background ~10px to the right then moving the complete title to the left ;?>
                
        <span id="large_image_title" style="color:#FFFFFF; display:block; width:100%; line-height:1em; padding-top:9px; height:20px; position:relative; top:-21px;left:-6px; background-image:url('<?php echo $gallery_url;?>/layout/transparent_bg.png'); background-repeat:no-repeat; background-position:12px 0px; text-transform:capitalize;"></span>
        
	</span>
    
    <?php 
	// the above complicated thing with do_with_delay (close_gallery/switch_photo) will allow to make a difference between clicking the photo 
	// or its parent element; then decide if it should show next photo (photo click) or close gallery (background click)
	?>
    
    </td>
  </tr>
</table>


<!-- thumbnails strip -->
<div id="thumbnails_strip" style="position:fixed; height:<?php echo round(($settings_thumbnail_height/2)+10);?>px; bottom:0px; left:0px; width:100%; background-color:#282828; border-top:1px solid #555555; text-align:center; padding:5px; display:none;">
    
    <span id="thumbnails_container" style="display:inline-block; white-space:nowrap; width:<?php echo count($categories_array[$category_title])*90;?>px; height:<?php echo round(($settings_thumbnail_height/2)+10);?>px; overflow:hidden;">
    <?php $photo_counter = 0;?>
    <?php foreach($categories_array[$category_title] as $photo_file){ ?>

    <img id="strip_image_<?php echo $photo_counter;?>" src="<?php echo $gallery_url;?>/<?php echo rawurlencode($category_title);?>/<?php echo rawurlencode($photo_file);?>_thumb.jpg" border="0" alt="" style="display:inline-block; float:left; cursor:pointer; border:5px solid #282828;" onmouseup="switch_large_image(<?php echo $photo_counter;?>);" width="<?php echo round($settings_thumbnail_width/2);?>" height="<?php echo round($settings_thumbnail_height/2);?>" />
	
    <?php $photo_counter++;?>
	<?php } ?>
    </span>
</div><!-- end of thumbnails_strip -->   

<script type="text/javascript"><!--
window.onresize = function(){ center_thumbnails_container();}
--></script>


<?php include("footer.php");?>

admin_categories.php

<?php

include("system_header.php");

admin_only();

$Category_Select = $_POST['Category_Select'];

// category doesn't exist
if(!is_dir("files/".$old_category_title)){
	header("Location: ".$gallery_url."/admin-categories?message=That category does not exist&message_type=error");
	exit;
}
// does category box have value
if(isset($_POST['category_title_box']) and $_POST['category_title_box']!=''){

	// was Category_Select selected
	if(isset($_POST['Category_Select'])){
		
		//yes, create folder within that folder
		$new_category_title = string_to_file_name($_POST['category_title_box']);
		
		mkdir('files/'.$Category_Select."/".$new_category_title);
		header("Location: ".$gallery_url."/admin-categories?message=Sub Category added&message_type=success");
		exit();
		
	}
	// add new category
	elseif(isset($_POST['category_title_box']) and $_POST['category_title_box']!=''){
	
	$new_category_title = string_to_file_name($_POST['category_title_box']);
	
	mkdir('files/'.$new_category_title);
	
	header("Location: ".$gallery_url."/admin-categories?message=Category added&message_type=success");
	exit;	
	}
}


// !!! delete category and all photos inside !!!
if(isset($_GET['category_to_delete']) and $_GET['category_to_delete']!='' and $_GET['key']==md5($_SESSION['session_secret'].$_GET['category_to_delete'])){
	rmdir_r('files/'.strip_tags(trim($_GET['category_to_delete'])));
	
	header("Location: ".$gallery_url."/admin-categories?message=Category ".$_GET['category_to_delete']." deleted&message_type=success");
	exit;
}

?>
<?php include("header.php");?>
<h1>Manage Categories</h1>
<p class="breadcrumb"><a href="admin.php">home</a> &gt; <a href="<?php echo $gallery_url;?>">gallery</a> &gt; <a href="<?php echo $gallery_url;?>/admin">admin</a> &gt; categories</p>

<?php if(count($categories_array)<=0){?>
<p>There are no photo categories, create one or more categories before uploading photos</p>
<?php } ?>


<form id="form1" name="form1" method="post" action="" style="margin:0px;">
        
    <label for="category_title_box">New Category Title</label><br />
		  <input name="category_title_box" type="text" id="category_title_box" size="20" />
          <br />
	  <br />
		   Select a current Category: <?php echo $Category_Select. "<br/>"; ?>
		   <select id="Category_Select" name="Category_Select" height="27px">
			<option value="" selected="selected">-----</option>
				<?php 
					foreach(glob(dirname(__FILE__) . '/files/*') as $filename){
						$filename = basename($filename);
						echo "<option value='" . $filename . "'>".$filename."</option>";
					}
				?>
		   </select>
		   <br />

          <input name="button" type="submit" class="button_190" id="button" value="Add category" style="margin-top:10px;" />
</form>

<script type="text/javascript">
document.getElementById('category_title_box').focus();
</script>

  
<?php if(count($categories_array)>0){?>

	<h2 style="margin-top:30px;">Existent categories</h2>
	
    	
    <table width="100%" border="0" cellspacing="0" cellpadding="10">
	<?php foreach($categories_array as $photo_category=>$photos_array){?>
    
    <?php
	if(!isset($row_color) or $row_color=='#F7F7F7'){
		$row_color = '#F1F1F1';
	} else {
		$row_color = '#F7F7F7';
	}
	?>
	
	<tr>
  
    <td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>
    
    <td width="300" height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>">
    
    
    
    <input name="button2" type="button" class="cancel_button_30" id="button2" style="float:right;" onmouseup="if(confirm('Delete category <?php echo htmlentities(addslashes($photo_category), ENT_QUOTES, "UTF-8");?> ? \nIt contains <?php echo count($photos_array);?> photos')){window.location='?key=<?php echo md5($_SESSION['session_secret'].$photo_category);?>&category_to_delete=<?php echo rawurlencode($photo_category);?>';}"  />
    
    <input name="button3" type="button" class="button_110" id="button3" value="Rename" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/admin-category-edit?category_title=<?php echo rawurlencode($photo_category);?>';"/>
    
    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>
    
    </td>
    
    </tr>

    <?php } ?>
    
    </table>
<?php } ?>

<?php include("footer.php");?>

System_Header.php

<?php

error_reporting(6135); 

include("settings.php");

$page_load_start = microtime(true);


if (!isset($_SESSION)) {
	session_start();
}

// this is needed to properly handle the special characters in file names, image resize might fail without this
setlocale(LC_CTYPE, "en_US.UTF-8");

$gallery_domain = str_replace("www.", "", $_SERVER['HTTP_HOST']);

// the gallery_url is the url of the gallery script (the folder), relative to site root, e.g /gallery
$gallery_url  = dirname($_SERVER['SCRIPT_NAME']);
$gallery_url = str_replace($_SERVER['DOCUMENT_ROOT'], '', $gallery_url);

error_reporting(E_ALL ^ E_NOTICE);

include("system_functions.php");

// test if this user is admin or not
$is_admin = false;

if($_SESSION['session_admin'] == md5($_SESSION['session_secret'].$settings_secret)){
	$is_admin = true;
}


// $photo_categories_array = array();
// $total_photos_array = array();

// this will be an array in array, first key is cat, second key is image file: 
// $categories_array['cars']['retro-car']
$categories_array = array();

$timer_1 = microtime(true);

/*
// loop over files directory and read the categories
if ($handle = opendir('files')) {
    while (false !== ($folder = readdir($handle))) {
		if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){
			
			// define this key in the array, it will be blank, store categories as keys
			$categories_array[$folder] = array();

			// $total_photos_array[$folder] = 0;
			
			$files_in_dir = scandir('files/'.$folder);
			foreach($files_in_dir as $file){
				// if file ends in _thumb.jpg
				if(strpos($file, '_thumb.jpg') === strlen($file)-10){
					// $total_photos_array[$folder]++;
					$base_file_name = substr($file, 0,  strlen($file)-10);
					// insert this file in the array of files
					array_push($categories_array[$folder], $base_file_name);
				}
			}
			
		}
    }
    closedir($handle);
}
*/

// loop over files directory and read the categories
$scandir_array = scandir('files');
foreach($scandir_array as $folder){

	if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){
		
		// define this key in the array, it will be blank, store categories as keys
		$categories_array[$folder] = array();

		// $total_photos_array[$folder] = 0;
			
		$files_in_dir = scandir('files/'.$folder);
		foreach($files_in_dir as $file){
			if($file!='.' and $file!='..'){
				
				// if file is not the category thumbnail (thumbnail.jpg) and not _thumb.jpg and not _small.jpg
				if($file != "thumbnail.jpg" and substr($file, strlen($file)-10) != "_small.jpg" and substr($file, strlen($file)-10) != "_thumb.jpg"){
					// $total_photos_array[$folder]++;
					$base_file_name = substr($file, 0,  strlen($file)-4);
					// insert this file in the array of files
					array_push($categories_array[$folder], $base_file_name);
					
					//echo "<br>$base_file_name";
					
				}
			}
		}
		
	}
}



$timer_2 = microtime(true);

// !! if you use wrong sorting parameter it will convert the category string keys into integer
ksort($categories_array);


// test if imagemagick is installed
$imagemagick_installed = false;
@exec("convert -version", $convert_output_array);
if(strpos($convert_output_array[0], "imagemagick")){
	$imagemagick_installed = true;
}


?>

Sorry, I meant in the first code, in category.php. I can see that it comes from the loop in admin_categories.php, but the loop in the earlier code is

	<?php foreach($categories_array[$category_title] as $photo_file){ ?>

So, which bit of your code is drawing the folder / subfolder list that you are having trouble with? I picked on the code in category.php because that’s the first place I saw the “Photos” and “Rename” buttons being drawn, and I figured the admin_categories.php script was where you add or remove folders and subfolders, rather than where you draw them.

category.php is where the issue lies. By default, the foreach loop cycles through a main directory/folder created from the admin_categories.php, which lists the folders/directories listed in one of the images below. From there, the user clicks on a folder from that list and is directed to the category.php script, which originally displays this:

<td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>

This is the line of code above that outputs this image:

When I want it to output something like this for a main folder that has subfolders/directories:

I still don’t see where $photo_category comes from, I must be missing it.

$categories_array is a detailed array of all categories created in system_header.php.
$photo_category is the array key in that loop, in this case array key would be category name (also folder name), then the =>$photos_array is the list of photos (formated as array) in each $photo_gategory

I’m still not seeing that in the code you posted for category.php. The code in admin_categories.php does that in the loop:

<?php foreach($categories_array as $photo_category=>$photos_array){?>

but not category.php.

<?php foreach($categories_array[$category_title] as $photo_file){ ?>

Unless I’m just not reading it properly.

That was my mistake. I changed it to the first foreach(). However, it brings up the directories in the main folder, not in its’ current directory.

<?php if(count($categories_array[$category_title])>0){?>
	<div style="display:block; margin-top:10px;">
    <?php $photo_counter = 0;?>
	<?php foreach($categories_array as $photo_category => $photos_array){ ?>
	<?php if(is_dir($gallery_url)){ ?>
    <img src="<?php echo $gallery_url."/".rawurlencode($category_title)."/".rawurlencode($photo_file)."_thumb.jpg" ;?>" style="padding:5px; border:1px solid #CCC; margin-top:5px; margin-right:5px; cursor:pointer;" onclick="switch_large_image(<?php echo $photo_counter;?>);" alt="<?php echo htmlentities(ucwords(str_replace('-', ' ', $photo_file)));?>" title="<?php echo htmlentities($photo_file, ENT_QUOTES, "UTF-8");?>" />
    <?php $photo_counter++;?>
    <?php }elseif(!is_dir($gallery_url)){?>
	
	<table width="100%" border="0" cellspacing="0" cellpadding="10">
    
    <?php
	if(!isset($row_color) or $row_color=='#F7F7F7'){
		$row_color = '#F1F1F1';
	} else {
		$row_color = '#F7F7F7';
	}
	?>
	
	<tr>
  
    <td height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>" style="text-align:left;"><a href="<?php echo $gallery_url;?>/<?php echo htmlentities($photo_category, ENT_QUOTES, "UTF-8");?>" style=" background-image:url('layout/folder_2.png'); background-repeat:no-repeat;   background-position:left center; padding:4px; padding-left:40px; text-transform:capitalize; text-decoration:none; font-size:14px;"><strong><?php echo htmlentities(str_replace('-',' ', $photo_category), ENT_QUOTES, "UTF-8");?> (<?php echo count($photos_array);?>)</strong></a></td>
    
    <td width="300" height="10" align="left" valign="middle" bgcolor="<?php echo $row_color;?>">
    
    
    
    <input name="button2" type="button" class="cancel_button_30" id="button2" style="float:right;" onmouseup="if(confirm('Delete category <?php echo htmlentities(addslashes($photo_category), ENT_QUOTES, "UTF-8");?> ? \nIt contains <?php echo count($photos_array);?> photos')){window.location='?key=<?php echo md5($_SESSION['session_secret'].$photo_category);?>&category_to_delete=<?php echo rawurlencode($photo_category);?>';}"  />
    
    <input name="button3" type="button" class="button_110" id="button3" value="Rename" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/admin-category-edit?category_title=<?php echo rawurlencode($photo_category);?>';"/>
    
    <input name="button3" type="button" class="button_110" id="button4" value="Photos" style="float:right; margin-right:10px;" onmouseup="window.location='<?php echo $gallery_url;?>/<?php echo rawurlencode($photo_category);?>/edit-photos';"/>
    
    </td>
    
    </tr>

    <?php } ?>
    
    </table>
	
	<?php } ?>
    <?php } ?>

Well, as you’re now using the same code, it will do. Instead of

<?php foreach($categories_array as $photo_category => $photos_array){ ?>

wouldn’t you want it to be more like

<?php foreach($categories_array[$category_title] as $photo_category => $photos_array){ ?>

So you’re still only iterating through the single title, but bringing the data out in the required format? Or does the structure of the array not support that?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.