That has me REALLY close. Heres the code. It displays 5 rows and 3 columns, but its all repeat data. (hope that makes sense). [code]// display categories on main page - gallery.php function display_categories($cats) { global $file; // Print Table print('<table id="display_categories" columnspan="3" rowspan="3">'."\r\n"); $rows = 5; $columnsPerRow = 3; for($r = 0; $r < $rows; $r++) { echo "<tr>"; for($c = 0; $c < $columnsPerRow; $c++) { /*print ('<pre>'); print_r ($cats); print ('</pre>'); */ foreach($cats as $key=>$value) { //while ($next = next($cats)){ //$key = key($cats); //$value = key($cats); $title = '<b>'.$key.'</b>:<br />'; //Output Thumbnail Images print('<td style="width: '. THMBWIDTH .'px; height: '. THMBHEIGHT .'px;">'); if(is_array($value)) { foreach($value as $k2=>$v2) { if(is_dir(PATH.$file.'/'.$key.'/'.$k2)) $subcats[$k2] = $v2; else $subimgs[] = $v2; } $imgloc = !empty($subimgs) ? rawurlencode($file.'/'.$key.'/'.reset($subimgs)) : null; $alt = !empty($subimgs) ? reset($subimgs) : 'no image'; // Show Gallery Main Image print('<a href="'.SELF.'?file='.rawurlencode($file.'/'.$key).'">'); print('<img src="imgsrc.php?src='.$imgloc.'" alt="'.$alt.'" />'); print('</a>'."\r\n"); // Gallery Information (Image size, gallery name, etc...) echo "<br>".$title; echo @count($subcats).' sub-categories<br />'; echo @count($subimgs).' images'; print('</td> <td class="category">'."\r\n"); unset($subcats, $subimgs); } else { print('<img src="imgsrc.php?src=null" alt="no image" />'); print('</td><td class="category">'."\r\n"); echo $title; print('0 sub-categories<br />'); print('0 images'); } print("\r\n".'</td>'."\r\n"); } } } echo "</tr>";} [/code]