Nevermind, I fixed it. But now I have another problem. One, my select box has some sub-directories. How cna I filter those out? It is also showing a bunch of numbers. I included a screenshot of the select box. The following is the code:
<?php function sortByTime($a, $b) { if ($a["time"] == $b["time"]) return 0; return ($a["time"] < $b["time"]) ? -1 : 1; } if($handle = opendir('/Inetpub/wwwroot/checker/modules/')) { while (false != ($file = readdir($handle))) { if ($file != "." && $file != "..") $files[] = array("file" => $file, "time" => filectime("/Inetpub/wwwroot/checker/modules/".$file)); } usort($files, "sortBytime"); echo "<select>"; while (list(,$filearr) = each($files)) { echo "<option value=\"".$filearr["file"]."\">".$filearr["file"]."".$filearr["time"]; } echo "</select>"; } ?> ----- Original Message ----- From: "Stephen" <[EMAIL PROTECTED]> To: "Nick Eby" <[EMAIL PROTECTED]> Cc: "PHP List" <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 8:28 PM Subject: Re: [PHP] Re: Show Folder Contents in Form > I finally got around to checking this thing out. Doesn't work... I'm getting > these errors: > > Warning: readdir(): supplied argument is not a valid Directory resource in > c:\inetpub\wwwroot\checker\admin\add_module.php on line 136 > > Warning: Wrong datatype in usort() call in > c:\inetpub\wwwroot\checker\admin\add_module.php on line 142 > > Any ideas why and how to fix it? > > > ----- Original Message ----- > From: "Nick Eby" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, December 02, 2002 4:16 PM > Subject: [PHP] Re: Show Folder Contents in Form > > > > you could first read the files and their modified-dates into an array; > sort > > the array; and finally build a select widget from the array... > > > > function sortByTime($a, $b) > > { > > if ($a["time"] == $b["time"]) return 0; > > return ($a["time"] < $b["time"]) ? -1 : 1; > > } > > > > while (false !== ($file = readdir("/some/directory/"))) > > { > > if ($file != "." && $file != "..") > > $files[] = array("file" => $file, "time" => > > filectime("/some/directory/".$file)); > > } > > > > usort($files, "sortBytime"); > > > > echo "<select>"; > > while (list(,$filearr) = each($files)) > > echo "<option value=\"".$filearr["file"]."\">".$filearr["file"]." > > ".$filearr["time"]; > > > > "Stephen" <[EMAIL PROTECTED]> wrote in message > > 000901c29a46$590a2320$0200a8c0@melchior">news:000901c29a46$590a2320$0200a8c0@melchior... > > > Hello, > > > > > > Is it possible, and if so how, to get the filenames and last edited > > > time/date, then display them in a select field in a form for a user to > > > select? I'd need to show them in order of most recently edited to last > > > edited. How can this be done if it can? > > > > > > Thanks, > > > Stephen Craton > > > http://www.melchior.us > > > > > > "Life is a gift from God. Wasting it is like destroying a gift you got > > from > > > the person you love most." -- http://www.melchior.us > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php