The link_range var is not changing anything when it's default value is changed... as I learned from you class this is supposed to have somethign to do with the number of numeric links on the left and right from the current page's number.

First, thanks for this class too ! It's simple, small, it was exactly what I need. Although I have modified it some place:

- line 14: I have added a new property (to get more professional class feeling :) ):
var $links_html = null;
- and line 21: $this->links_html = '';
- and line 74,80,87,92,99,105: change the echo to this:
$this->links_html .= .......
- and line 107: return $this->links_html;
- so in line 38: change the method name to: GetLinks()

There was a problem in the class, when a user change the value of the offset by hand (at the address bar) to a value that is greater then the total: in this case there were no displayable records, because the query is based upon the offset value. That's why I have changed the constructor to this:
- line 16: function MyPager($_total, $limit = 10)
- line 19: change to this: $this->total = $_total;
- line 22-29: It wasn't really a problem the condition (beside of the missing total condition), but I prefer that the user do as little harm as possible, so I have modified the condition to this:
if ( ! isset($_GET['offset'])
|| ! ( (string)(int)$_GET['offset'] === (string)$_GET['offset'] && $_GET['offset'] >= 0 )
|| $this->total-1 < $_GET['offset'] )
$this->offset = 0;
else $this->offset = $_GET['offset'];
the difference between the two, if the value of the offset is:
val 1st 2nd
x5 -> 0 0
5a -> 5 0
-5a -> 5 0
+5a -> 5 0
05 -> 5 0

- at last line 125: to have all values in 1 array:
return array($this->offset + 1, $upper, $this->total);

The sample file is only changed some place. The most important thing is that the query in line18-19 must have executed before the instance of the class is constructed.

If you like these changes, feel free to modify your class. If not, no problem :)

- in those lines, where you have created the links, I have added a 'title' property to the 'a' tag, which shows the number of page and the number of items on it (for this I have created a variable from the offset count, that you have done), eg at the case of the prev link:
if ($current_page != 1 && $this->on_prev_next) {
$_offset = ($current_page - 2) * $this->limit;
$href = $url . 'offset=' . $_offset;
$this->links_html .= "<li><a href=\"$href\" title=\"Prev page: ".($_offset+1)."-".($_offset+$this->limit)."\">&lt;</a></li> \n";
}

- and last I have added a new simple method called GetOffset():
/**
* Returns the offset based upon the rank of the element
*
* @param int $rank the rank of the element
* @return int returns the offset number
*/
function GetOffset(&$rank)
{
return floor($rank / $this->limit) * $this->limit;
}

It can be used to reference to an element by id:
In the main script I have selected the rank value of the desired id (of course, after the examination, that the id is still exist), and this method returns the offset, so I can reference a news item by id from the web (or after editing, or when a news item has deleted I have selected the next available id):
eg. the referece-link:
- http://www.filter.lan/index.php?page=news&p=12
and the main script generated link, with the help of this method, is:
- http://www.filter.lan/index.php?page=news&offset=10#p12