Hi bud,
here is one that i have used for awhile, it was done for me as a favor by a very experience coder awhile back
have used it alot and it works great
its pretty simple and it also does what you say,
and it allows you to set the range on either side of the page you are on.
i use ps pagination and it does a query and then load the value in $rs
and then i just copy the vars from that result from the pagination array into my little script
basically i changed from using the pagination display output to my own thats why i copied the results from the array here
here ya go, maybe if you look at this it will give you some hints bud.

hope it helps.
PHP Code:
//also the record_per_page is set up here as well before the query
// the query is done up before this
$pager = new PS_Pagination($link,$query,$record_per_page,5);
$rs = $pager->paginate();
//############# added for page number display
// i take what need from the pager array
$maxpg = $pager->max_pages;
$curpg = $pager->page;
$rppg = $pager->rows_per_page;
$off_setpg = $pager->offset;
function pag_links() {
global $curpg, $maxpg;
/****** build the pagination links ******/
// i believe this is the part your looking for
// range of num links to show on either side of current page
$range = 5;
// show $range pages on either side of current page. if this includes page
// 1, don't show "First". if this includes last page, don't show "Last"
// show back links |< and < unless at page 1
if ($curpg > 1) {
if ($curpg - $range > 1) { // wouldn't show page 1 in range
// show << link to go back to page 1
echo "<a href='{$_SERVER['PHP_SELF']}?page=1'>|‹</a> ";
}
// get previous page num
$prevpage = $curpg - 1;
// show < link to go back 1 page
echo "<a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>‹</a> ";
}
// loop to show links to range of pages around current page
// if previous page <, there is a space after it
for ($x = $curpg - $range;
$x < $curpg + $range + 1;
$x++) {
// if it's a valid page number (not < 1 or > last page)...
if ($x > 0 && $x <= $maxpg) {
// if we're on current page, not a link...
if ($x == $curpg) {
// 'highlight' it but don't make a link
echo "[<b>$x</b>] ";
} else {
// if not current page, make it a link
echo "<a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> ";
}
}
}
// if not on last page, show forward > and last page >| links
if ($curpg < $maxpg) {
// get next page
$nextpage = $curpg + 1;
// echo forward link for next page
echo "<a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>›</a> ";
// echo forward link for lastpage, unless last page already showing
if ($curpg + $range < $maxpg) {
echo " <a href='{$_SERVER['PHP_SELF']}?page=$maxpg'>›|</a>";
}
}
//echo "</span>";
/****** end build pagination links ******/
} // end pag_links()
and then to show it just do this somewhere on your page
PHP Code:
<?php
if(mysql_num_rows($rs)>0){
pag_links();
} ?>