Re: pagination code not incrementing page numbers.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux