Re: pagination code not incrementing page numbers.

From: Date: Tue, 24 Oct 2006 04:18:57 +0000
Subject: Re: pagination code not incrementing page numbers.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-243553@lists.php.net to get a copy of this message
Mark wrote:
I am using the following code for pagination with php5 and mysql 4.1.x The pages advance by clicking on the "Next" or "Last" link However the url does not advance past this in the url field http://localhost/page.php?pagenum=2 Also the page count does not increase past "--Page 1 of 50--" at the bottom of the page regardless of how many pages forward I have clicked. If anyone could point me in the right direction to fix this, it would be much appreciated. Code: // Connects to your Database mysql_connect("dev", localhost", "user", "password") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; }
if (!isset($_GET['pagenum'])) { $pagenum = 1; } else { $pagenum = (int)$_GET['pagenum']; } You have register_globals off (good thing) so you need to change how you fetch the information. If it's in the url, it'll be in $_GET somewhere. This: $pagenum = (int)$_GET['pagenum']; Will make sure that $pagenum is a number so I can't change it: ...?pagenum=<script>alert('xyz');</script> -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#243553) next »