Phenomena Posted July 5, 2007 Share Posted July 5, 2007 Ok so what I'm trying to do is set up a directory that will contain a bunch of different web pages and have any web page in that one directory linked on the nav.php automatically. Lets say I have 3 files in my stuff/ directory, named file1.php, file2.php and file3.php. In the nav.php I want a script that will generate this html for every page <a href="/stuff/$file">$name</a> where $file is the file name in the directory, and $name is a variable defined within the file its self. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 Well, generating a list of all the files in the directory is reasonably straight forward. Take a look at the examples on the php website for readdir() You could then use the fread() function to get the contents of each file and find your name. Quote Link to comment Share on other sites More sharing options...
Phenomena Posted July 5, 2007 Author Share Posted July 5, 2007 thanks so much i got it working the only problem is that it also creates a link to the directory itself and to the sites homepage. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 You'll need to put in a little validation. Use something like this in your while loop: <?php if($file != '.' && $file != '..'){ echo $file; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.