Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: Pagination isn't working Date: Sun, 3 Apr 2016 10:30:43 +0200 Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net W0odPhVEDDA2pyQ3pfPKHwXHLgLUYefx9pCVSIhI5L9ZngdHa0 Cancel-Lock: sha1:DFXKNl243twVm/vNxkqUUHX42Sc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 In-Reply-To: Xref: csiph.com comp.lang.php:16717 On 04/02/2016 11:04 PM, super70s wrote: > I have a little PHP article directory script with pagination at the > bottom, but it isn't working when you click on pages 2, 3, 4, etc., -- > it always shows the same 10 entries on the first page. Anyone have an > idea how I can fix this? > > Go To Page : >   [1] >   class=bodylinks>2 >   class=bodylinks>3 >   class=bodylinks>4 > you need to add $this->ps to the variable you use for setting the ?pg= > if (!empty($_GET["ps"])) > $this->ps = (int) $_GET["ps"]; > else > $this->ps = 50; I wouldn't use empty() to verify that the user input is correct, use a regular expression or in worst case is_numeric() to validate the input. -- //Aho