![]() |
| HTML | PHP Scripts | Webmaster Tools | Webmaster Forums | Web Hosting | Domain Names | Webmaster Books |
|
|||||||
![]() |
|
|
Thread Tools | Rate this Webmaster Discussion |
|
|
#1 |
|
New Member
Join Date: Oct 2009
Webmaster Discussions: 1
Rep Power: 6 ![]() |
PHP for automatically generating file/link list with file titles
I keep a website for all my classes, and one of the pages is a Downloads page where students can get all the documents I pass out in class. In the past, I manually added to the list in a normal HTML document, but I'd like to switch to PHP so the list is generated automatically. I tried the script below and it works just fine, but it generates a list of file names. Is it possible to have this (or another code) generate the actual file titles? For example, it'd be easier for my students to see Chapter 1 Vocabulary rather than av1_ch1_vocab.pdf.
I'm fairly clueless when it comes to PHP, but I can copy and paste and work with typical HTML. I'd really appreciate your help in shaving off a few minutes of website updating every day!The current PHP I'm using is: <ul> <? // Define the full path to your folder from root $path = "/rhsfrench/downloads/"; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || $file == "index.php" ) continue; echo "<li><a href=\"$file\">$file</a></li>"; } // Close closedir($dir_handle); ?> </ul> |
|
|
|
|
|
#2 |
|
Join Date: Aug 2008
Location: Texas
Webmaster Discussions: 501
Rep Power: 21 ![]() ![]() ![]() ![]() |
Re: PHP for automatically generating file/link list with file titles
If you are consistent in your file names, you can create the display name based on the actual file name.
For example: File Name: av1_ch1_vocab.pdf PHP code to get the Display Name of each file: PHP Code:
__________________
Be sure to click the reputation icon to give rep to the person who helped you. For web design/development services, check Silentium Designs. |
|
|
|
![]() |
| Bookmarks |
| Tags |
| file or link, php |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Webmaster Discussions
|
||||
| Thread | Webmaster Discussion Starter | Forum | Replies | Last Post |
| Need help creating a dvd inventory list from a CSV file | aldar | HTML Forum | 5 | 08-22-2008 03:50 PM |
| How to print a html file to a specific printer automatically | stoopenf | Website Scripts Forum | 0 | 08-10-2005 03:33 AM |
| how to make a css file to link to your webpages | Main Source | CSS Forum | 1 | 01-15-2004 12:30 AM |
| How to Insert a Link That Will Download a File | rowdyr | HTML Forum | 2 | 04-11-2003 08:51 AM |
| Help with file link | switherow | HTML Forum | 7 | 07-31-2001 01:34 AM |