apple 0 Report post Posted August 10, 2006 I want to display the contents of a directory..i have the following code..It gives the output in one column only... likefile1file2file3file4.....Since there are lot of files so this column gets very long..i want to display the x number of files in each column..like if there are 22 files..thenfile 1 file 11 file 21file 2 . file 22file 3 .....file 10 file 20This was just an example..I know it can be done by using <td> but i dont know how to do it with loop.Please help me. $dir = './'; $handle = opendir($dir); //$count = 0;while (($file = readdir($handle)) !== false) { if ( !in_array($file, array('.', '..') ) ) { echo basename($file, '.php') ."<br />\n"; //$count++; } } //print "$count";closedir($handle); Share this post Link to post Share on other sites
anonymal 0 Report post Posted August 14, 2006 Here's another one: function dirList ($directory) { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($directory); // keep going until all files in directory have been read while ($file = readdir($handler)) { // if $file isn't this directory or its parent, // add it to the results array if ($file != '.' && $file != '..') $results[] = $file; } // tidy up: close the handler closedir($handler); // done! return $results; } But I want somebody to help me on haw to delimit the number of items I want to be displayed in this code. I mean I want to put Next and Previous buttons. dividing the results through paging. Share this post Link to post Share on other sites
electron 0 Report post Posted August 15, 2006 Thats simple. You could limit it with the number of files you want to display and then using the GET VAR get the page number accordingly and then show the results. Share this post Link to post Share on other sites