listing file names from a directory -- 10 at a time???
Posted: Wed Nov 10, 2004 3:43 pm
Hi,
I have a task I am stuck with and hope I'll get some help here. My problem follows...
I need to list filenames from a directory but only 10 at a time. Say the directory has 25 files then the first 10 file names should get displayed on the webpage and a link saying 'Next' at the bottom of the page, clicking which should show the next 10 file names.
Ex:
file1
file2
file3
file4
file5
file6
file7
file8
file9
file10
Next...
When clicked next...
file11
file12
file13
file14
file15
file16
file17
file18
file19
file20
Next...
Presently I am using the following code to display all the file names at once...
In simple words, I want to limit the display of filenames from a directory to 10. Can anybody please help me???
Cheers.
I have a task I am stuck with and hope I'll get some help here. My problem follows...
I need to list filenames from a directory but only 10 at a time. Say the directory has 25 files then the first 10 file names should get displayed on the webpage and a link saying 'Next' at the bottom of the page, clicking which should show the next 10 file names.
Ex:
file1
file2
file3
file4
file5
file6
file7
file8
file9
file10
Next...
When clicked next...
file11
file12
file13
file14
file15
file16
file17
file18
file19
file20
Next...
Presently I am using the following code to display all the file names at once...
Code: Select all
$path = 'logs/';
$mydir = dir($path);
while(($file = $mydir->read()) !== false) {
if($file !== "." && $file !== "..") {
echo "<a href='readfile.php?filename=$path$file'><font face='verdana' size='2' color='#a00000'>$file</font><br>";
}
}
$mydir->close();Cheers.