In order to provide page # links as you have described, your code will need to determine how many total pages exist (this totally depends on your code and what is being displayed, there is no rule of thumb to be applied here). once you know what constitutes a page, then you'll need to keep track of what page # where the user is located. If you know the current page and the total page, then the rest is fairly simple.
Given your example:
1. Are they on the first page? If not, print the <<first and <prev links. If so, skip them.
2. Loop through the pages, 1 to total_pages. if loop # == page_on #, then ignore the link portion and surround it with 's.
3. Are they on the last page? If not, print the next> and last>> links. If so, skip them.
How you pass the current page number into the script via the URL, and how you determine the total # of pages, is your call.
Does this give you enough to go on?