Re: pagination example?

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

 



the part

$page = (!is_numeric($_GET['page'])) ? '1' : round($_GET['page']);

i believe can help prevent sql injection... i rounded the $_GET['page'] as well in case someone tries to put in decimals and ruin the query

the $perpage is the number of rows you want to display


xkorakidis wrote:

>hmmm,
>it seems simple, althought I didn't yet understand what exactly takes
>part in
>$page = (!is_numeric($_GET['page'])) ? '1' : round($_GET['page']);
>it seems like a c expression : if page is not numeric page=1 else round
>page?
>How does the $perpage increase?
>couldn't we use smth $page++ ?
>Thanks.
>
>Unnawut Leepaisalsuwanna wrote:
>  
>
>>$perpage = 10;
>>$page = (!is_numeric($_GET['page'])) ? '1' : round($_GET['page']);
>>
>>$page = ($page-1) * $perpage;
>>$sql = 'SELECT * FROM `table` WHERE 1 LIMIT '. $page .', '. $perpage;
>>
>>something like this?
>>
>>xkorakidis wrote:
>>
>>    
>>
>>>Hi, I'm trying to find a simple example for pagination in php-mysql. I
>>>found smth in php classes but it seems too complex (3-4 files and things
>>>not so simple). Is there any simple way to do that?
>>>Thanks.
>>>
>>>
>>>
>>>      
>>>
>>    
>>
>
>  
>


-- 
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.1 (MingW32)

mQGiBEKI4BsRBACgj8tsbHAvQNmDao4v0FA5UU++ripJXitp4R0AKUfSnC89x9vO
Ox39Ip6Cjvw7/TAYmZsOPKjHgL+j+aoz/hBWQBPkOScNQ3Tehc2RrpJd4f2rO+1n
Rx5YeRLFIL7kII27rFisQNH3xWk+Srgml6tsiOsYAho+fwMAGc0IYr0alwCgjQ+D
BQPpTIJSvZxJ2S2Q3e7tJB0D/0o27C6KOFcUIJKAi++DydXH7iWab/E8mLGFv0Ol
tG/XNJWBo0p00bTrj93PoJ0zTsnZamuyfstzwGX/BqLQaCqGufpxD82jHxHC4SQC
3M3zXScYRfBeGU1ihIeQnbyH1zQeb5kq2ObmxzysBHXbTqSCE/aMEH0CxvNsGGNJ
KQ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MDkMOtqris97Rw9Rm4MRNELgl4KlItMg7o3r2ca/GufiEkE
GBECAAkFAkKI4CkCGwwACgkQey8SxD/BmXK96wCfahapDeGs55QdeyZFsWrXejiv
AtoAnjL/op77uRrkO8G+bm/H1xS5yJx1
=zCme
-----END PGP PUBLIC KEY BLOCK-----

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux