Firstly, thank you OpzMaster. I shall indeed PM you with the new version when it is completed.
For a fully detailed explanation you can see it explained here: http://uk3.php.net/manual/en/language.oop5.basic.php
(It’s basically an advanced function - only it’s multiple variables and functions collaborated into one object/“class” and all are contained within that class and must be referenced from that class, unlike regular variable/function initialisation)
In the case of this one section of script, provided you aren’t going to want to change any attributes of the pagination, my function will not be of use and will simply bloat your code. However, for reference see below it’s advantages:
[ul][li]The $_GET variable can be changed in one place, and will work throughout the script without changing anything else - it can also be ignored entirely and it will default to ‘page’[/li]
[li]Unlike your example, it not only checks for the page number to be specified, but it also ensures that it is a valid page number that will actually show results, if not, it defaults to 1[/li]
[li]If you place the function in a globally included file, you can use it anywhere on the site with just a couple of lines (calling the function and outputting)[/li]
[li]If you use mod_rewrite, your $_GET variables can be protected and not re-written using the $ignoregets array. Meaning that the urls it creates leaves the $_GET variables specified in $ignoregets and only appends any left out, plus the ‘page’ variable[/li]
[li]You can customise the ‘previous’ and ‘next’ links at each call of the function (or leave blank for the defaults)[/li]
[li]You can specify how many page numbers to list (“2,3,4,5” or “3,4” or “1,2,3,4,5,6,7”) between your previous and next links.[/li]
[li]The amount of items shown per page is easily changed on each call of the function[/li][/ul]
The main downside is the fact that you need to feed it the full set of data on each page load - although this doesn’t matter for smaller sites/projects, large projects that will be pulling large amounts of data from databases etc will no doubt suffer performance issues. This will be addressed in the new version.
If you have any other questions, or want me to give some example uses just let me know.