I cant seem to find the problem... currently the script im running is supposed to display the main directories , and when you click it it should display the subdirectories. whats happening is that its listing all the directories on the same page... here is the php file. Thanks! <?php $cdir = dirname(__FILE__); $DirectoriesToScan = array(realpath($cdir)); $DirectoriesScanned = array(); while (count($DirectoriesToScan) > 0) { foreach ($DirectoriesToScan as $DirectoryKey => $startingdir) { if ($dir = @opendir($startingdir)) { while (($file = readdir($dir)) !== false) { if (($file != '.') && ($file != '..') && ($file != 'files')) { $RealPathName = realpath($startingdir.'/'.$file); if (is_dir($RealPathName)) { if (!in_array($RealPathName, $DirectoriesScanned) && !in_array($RealPathName, $DirectoriesToScan)) { $DirectoriesToScan[] = $RealPathName; $DirList[] = $RealPathName; } } } } closedir($dir); } $DirectoriesScanned[] = $startingdir; unset($DirectoriesToScan[$DirectoryKey]); } } $DirList = array_unique($DirList); sort($DirList); echo "<br><table align=center width=100%>\n"; $columns=3; $i = 0; foreach ($DirList as $dirname) { if ($i == $columns) { echo "</tr><tr>"; $i = 0; } elseif ($i == 0) { echo "<tr>"; } $i++; $dirnames = str_replace("$cdir/","",$dirname); $back_root = dirname(__FILE__) . '/..'; $back_root = str_replace("/..","",$back_root); $back_root = str_replace("$cdir/","",$back_root); $back_root = str_replace("$root/m/","",$back_root); $dirnames = str_replace(" ","_",$dirnames); $count = count($DirList); if (strpos($dirnames,"/")){ $list_name = explode("/",$dirnames); echo "<td> <span style=\"text-transform: uppercase\"><a href=\"?page=filter&location=$dirnames§ion=$back_root\">$list_name[1]</font></a> </td>\n"; }else{ echo "<td> <span style=\"text-transform: uppercase\"><a href=\"?page=filter&location=$dirnames§ion=$back_root\">$dirnames</font></a> </td>\n"; } } for ($x=$i; $x<$columns ; $x++) echo "<td></td>"; echo "</tr></table>\n"; ?> PHP: