Jump to content


Photo

php subfolder listing


  • Please log in to reply
8 replies to this topic

#1 madspof

madspof
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 03 September 2006 - 01:57 PM

i am looking for a script that will list sub folders and give them a link

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 September 2006 - 02:11 PM

Do you also want nested subfolders?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 madspof

madspof
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 03 September 2006 - 02:16 PM

sorry i am quite a newbie but i am learning what are nested subfolders ?

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 September 2006 - 02:40 PM

folders inside folders inside folders .......
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 madspof

madspof
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 03 September 2006 - 02:41 PM

it does'nt have to  be nested what ever is easier for you tho i would prefer nested

#6 madspof

madspof
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 03 September 2006 - 02:59 PM

it does'nt have to  be nested what ever is easier for you tho i would prefer nested

#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 September 2006 - 03:09 PM

This will list folders and their nested subfolders
<?php


function listSubFolders ($dir, $level=0) {
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir("$dir/$file")) {
                    $indent = str_repeat('---', $level);
                    echo "$indent $file<br>";
                    listSubFolders("$dir/$file", $level+1);  // list subfolders of this folder
                }
            }
        }
        closedir($handle);
    }
}

$dir = 'c:/inetpub/wwwroot';       // <-- specify folder
listSubFolders($dir);
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#8 madspof

madspof
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 03 September 2006 - 03:14 PM

this is very good but i cannot see a way of the script being able to make a link to the folders


#9 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 September 2006 - 03:17 PM

Add
<a href='.....'>...........</a>
tags.

Thought I'd leave you something to do.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users