What you need to do is similar in some ways, even though you won't be using mysql. Think of your directory structure as being a type of database (which it really is anyway.)
Let's assume your directory listing always comes back in a predictable order, then you can do something like this:
<?php
First read in all the files.
while ($file_name=readdir($dir)) {
if (($file_name!="." && $file_name!="..")) {
$files[]=$file_name;
}
}
closedir($dir);
$numfiles = count($files);
$size = 20;
if (!isset($offset)) $offset = 0;
for ($i=$offset;$i<$size;$i<$offset+$size){
print $files[$i]."<BR>";
}
print "<form name=form>";
if ($offset>=$size) {
print "<input type=submit name=offset value=" . $offset-$size . ">";
}
if (($offset+$size)<$numfiles){
print "<input type=submit name=offset value=" . $offset+$size . ">";
}
?>
This code is untested and may not work right, but it gets the idea across.