i've seen a couple threads on this but they deal with it from a mysql query

in my database i got a directory location
using that location i got a list of all the .jpg files in that directory and put them into an array

i want to display 20 files at a time, then at the bottom have previous and next links. the will reload the page with the next 20 pictures (or previous 20).

someone suggested to me using count() but i can't see how i'd do that. also.. is there a way i could display it all the page links at the bottom of the page? like if it 53 pics, at 20pics a page, there'd be 3 pages. at the bottom of the page have it have links to page 1 - page 2 - page 3

like for these forums. any help?