简单的opendir()与分页

I am very new in php, though was wable to make opendir() work (just show list of files in a table) now I have a problem of creating a pagination. Sorry I have been working with tutorials out there but can't make them work.I quick help would be very much appreciated.

here's my code:

$dir = 'files/memoranda'; 
$exclude = array('.','..','.htaccess'); 
$y = (isset($_GET['y']))? strtolower($_GET['y']) : ''; 
$res = opendir($dir); 

while(false!== ($file = readdir($res))) { 
if(strpos(strtolower($file),$y)!== false &&!in_array($file,$exclude)) { 
echo'
    <div class="Row">
        <div class="Cell">
            <h4><a  href=" ' . $dir .  '/' . $file . ' ">'.$file.'</a></h4>
        </div>

        <div id="Cell" style="text-align: center;vertical-align:middle;border-top:solid 1px #cecece;">
            <h4><a href=" ' . $dir .  '/' . $file . ' "><img style="text-align:center;padding-top:6px;" src="icon_download.png" width="30px" height="30px" ></a></h4>
        </div>
    </div>
';

} 
}