Directory / File Indexing - Structure Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
As part of learning php I have set up an automated directory/file listing  

On my server I have a directory called 'Notes' and under that a dozen or  
so dub-directories on various topics, each containing a mix of html and  
mht files.

In the Notes directory I have a php script which echoes links to each sub  
directory (excluding . and ..) and incorporates a link to a file  
'index.php' in each sub directory.

In turn index.php echoes the html/mht files along with a link to them.

This means that I can add/remove directories and files and they will  
automatically be included in my browser, as long as I remember to copy  
index.php to each new directory.

I want to change this slightly so that clicking on a link in Notes.php  
will write a file called index.html to the selected sub directory and then  
navigate to it. This avoids having to copy index.php to each sub directory.

I am OK with most of it except how to switch to the index.html file from a  
php file. I read a comment somewhere that php is not html so doesn't  
recognise links so is there a way to switch to a specified file in a  
browser from a php script please? Having re-read this I need a process  
that can call a function then activate a link to index.html in the  
appropriate directory.

Many thanks.

Jeff Gaines Damerham Hampshire UK
There are 10 types of people in the world, those who do binary and those  
who don't.

Re: Directory / File Indexing - Structure Question

Quoted text here. Click to load it

I think you are looking for the header() function

Re: Directory / File Indexing - Structure Question

On 15 Oct 2007 12:07:54 GMT, Jeff Gaines wrote...
Quoted text here. Click to load it

I think most PHP is setup on teh web server so all .php files are parsed by PHP.
IF the file extension is .html then it would be a plain HTML file that us sent
as-is. If you didn't need any PHP code in the index pages you are creating in
those directories, it would make sense to simply use the .html version .

NewsGuy Takes Usenet Cellular!
Download newsgroup MP3's to your Cell or PDA
Free Trial -

Re: Directory / File Indexing - Structure Question

Quoted text here. Click to load it

Many thanks Captain P and Tom, I will investigate the header() function.

In the meantime I have taken a slightly different approach. I have  
book-marked CreateIndexFiles.php as my entry point to my notes files. The  
script then creates an index.html file in each sub-directory and echoes a  
link to each of those index files. This means if I add/delete a directory  
or file then I just navigate to the bookmark, hit Ctrl+F5 and it gets  
re-built automagically.

If anybody has any other suggestions as to how to achieve this I would be  
happy to try them as part of my learning process :-)

Jeff Gaines Damerham Hampshire UK
There are 3 types of people in this world. Those who can count, and those  
who can't.

Site Timeline