Reply
Sort order of website file folders
Old 04-08-2008, 05:51 PM Sort order of website file folders
Novice Talker

Posts: 12
Name: Lynne
Hello,

Below is the code I am using as an index.php file inside a file folder that I want web guests to be able to view the contents of. Everything is working great except that the files are not in the correct alphanumeric order, so I think I need to add a piece of code to tell it to do so, but being a novice at php, I am unsure what to add. (I do have the u/s/e/Username field correct for my file name, so no worries there. Like I said, everything works except sort order.) Could someone look at my code below and tell me what I need to get it to sort my files in ascending alphanumeric order by their file name? What I do is upload all the Word documents to the server through Word and then instead of having to create a link for each document, the files appear right in the folder for viewing on the Internet. Please help! Thanks! :-)

<?
/**
* Change the path to your folder.
*
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory.
*/
// Define the full path to your folder from root
$path = "/home/content/U/s/e/Username/html/Folder/2000/";
// 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 "<a href=\"$file\">$file</a><br />";
}
// Close
closedir($dir_handle);
?>
CookieMonster21 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-09-2008, 01:30 AM Re: Sort order of website file folders
mtishetsky's Avatar
King Spam Talker

Posts: 1,063
Name: Mike
Location: Mataro, Spain
You will have first to put all filenames into array, sort it and only then output instead of outputting them immediately.
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 04-20-2008, 12:16 AM Re: Sort order of website file folders
Novice Talker

Posts: 12
Name: Lynne
Do you have the code I need for that? Sorry, I am a TOTAL novice at php. Thanks for any help you can provide on my little project. :-)
CookieMonster21 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Sort order of website file folders
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11412 seconds with 12 queries