i want my navigation include to be almost fully automatic, at the moment it opens the already specified dirs and runs out a list of the files within that are put into a link for the user to click on to navigate the site...
but what i want to do now is add the option to check if there is a dir and then if there is to display the files within the new dir...
i know the code i need to use except the is_dir seems to ignore the dirs and if i use is_file it doesnt show anything including the files...
this code tests for all files in the dir: (commented out the is_file if statement)
$dir = "admin/";
echo "<br><br>Files:<br>";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ( $file != "." && $file != ".." ){
// if (is_file($file)) {
echo "<li>Filename: ".$file."</li>";
// }
}
}
closedir($dh);
}
}
and here is the code for the dir test (commented out is the is_dir):
$dir = "admin/";
echo "<br><br>Dirs:<br>";
if (is_dir($dir)) {
if ($dh2 = opendir($dir)) {
while (($file2 = readdir($dh2)) !== false) {
if ( $file2 != "." && $file2 != ".." ){
#-------------------------------------------------------------------------
if (is_dir($file2)) {
if ($newdir = opendir($file2)) {
while (($newdir2 = readdir($newdir)) !== false) {
if ( $newdir2 != "." && $newdir2 != ".." ){
//if (is_dir{$newdir2}} {
echo "<li>Dir Name: ".$newdir2."</li>";
//}
}}
closedir($file2);
}
}
#--------------------------------------------------------------------------
}
}
closedir($dh2);
}
}
now with the is_file and is_dir commented out, the files part shows this:
Files:
Filename: Edit_Member.php
Filename: News
and the dirs part shows this: (again without the is_file and is_dir)
Dirs:
right so if i enable the is_file and is_dir this is what shows:
Files:
Dirs:
any ideas?