It's an old tutorial that assumes your Register Globals setting is ON in the php.ini file... (and I'm 99.99999% certain your Register Globals setting is OFF like it should be). In the older days of PHP, it was on by default, but recent revs (I think since 4.1, but don't quote me on that) it is off by default.
So, what's happening is when you get to this line:
if(empty($page)){
$page = 1;
}
Your code doesn't already have a $page variable, and thus; it is always defaulting to page 1. Consequently, anytime you are referencing the $page variable, it is always defaulting to 1, so the rest of your code doesn't behave as you would expect.
Change it to look like this:
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
Now, this is minimal error checking, and one could replace the URL's variable with a different number manually, which could cause some odd results, so you'd want to add more error checking to confirm that $_GET['page'] [man]is_numeric[/man] and that the number is <= your $numofpages variable... (which you would need to define before you defined your $page variable.)
Not sure who submitted this toturial to PHP Freaks, but it's mediocre at best. It looks like it gives basic principals, but doesn't touch on the important things too well. I'm not saying scrap the tutorial... just be wary. (No offense if any other poster here recognizes this code as their own). Oh, and when you find tutorials, remember to look for discussions about them. That tut was rated a 3.25 out of 5. That's a failing grade in school, and should tell you something. Also, there are a lot of negative comments about that tutorial. Read 'em. It's good readin'!