If I am not mistaken (and I often am 😉 ) you need to add the path to your file before you check if it's a directory. try this in your inner loop:
$a2 = opendir($path);
while ($b2 = readdir($a2)) {
$path2 = $path."/".$b2;
if ( (is_dir($path2)) and ($path2 != ".") and ($path2 != "..") ){
echo "<a href=$path2/><font color=blue>...... $b2</font></a><br>";
}
}
closedir($a2);
As for your outer loop, I'm with dalecosp. You need to pass the relative path to your function and not getcwd(). Not to be picky, but in the manual they say the "proper" way of reading a directory is
while(false!==($file=readdir($directory_handle))){
blah blah
}
But hey one thing at a time right?
HTH