GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 30-Mar-2007, 08:49
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 225
Kacyndra will become famous soon enough

List 10 latest modified files


i currently have this:

PHP Code:

$handle=opendir($upload_dir);
$filelist = "";
$counter = 0;



while (($file = readdir($handle)) && ($counter <=11) ) 
{
    
       if(!is_dir($file) && !is_link($file)) 
       {
          //$filelist .= "<a href='$upload_dir$file'>".$file."</a>";
          $filelist .= $file;
          if ($DELETABLE)
          {
           $filelist .= " <a style='text-decoration:none; font-weight:bold'  href='?del=$upload_dir".urlencode($file)."' title='delete'>x</a>";
          }
            
           $filelist .= " Added at  ".date("d-m H:i", filemtime($upload_dir.$file))
                       ."";
    
          $filelist .="<br>";
       }
   $counter = $counter +1;
} 



which shows 10 oldest files, how do i sort them by date?
i need the most recent ones....
Thanks!
__________________
Xrum!
  #2  
Old 30-Mar-2007, 20:27
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: List 10 latest modified files


Unless someone else proposes something more efficient, I would suggest you save the filename, path and the results of filemtime into an array. Then you sort the array before listing it on a web page?
 
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ class -- Please help vnca_1 CPP / C++ Forum 3 14-Jun-2006 12:31
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
Help in C Print is not working with LinkList batman3280 C Programming Language 3 09-Mar-2006 19:03
linked list error message Krandygrl00 CPP / C++ Forum 4 22-Jun-2005 14:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:20.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.