How would I get my pagination to be like this:

1 2 3 . . . . 57 58 59


I have too many records now to have all the page links displayed.

Here is the code for this part:

PHP Code:
for($i 1$i <= $numofpages$i++){
        if(
$i == $page){
            echo(
$i." ");
        }else{
            echo(
"<a href=\"$_SERVER[PHP_SELF]? 
At the moment it displays them as

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20