A good google search will provide you a few hundred example, but there are some styles used over and over.
Basically, the trick is to get the total number of items to display, and the number to display. Next, you want to get the items between page_number * number_of_items_per_page and (page_number +1) * number_of_items_per_page.
Have a look at the examples in the related links.