pagination example?

pagination example?

am 23.11.2005 10:51:45 von xkorakidis

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.

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

Re: pagination example?

am 23.11.2005 11:52:28 von Unnawut Leepaisalsuwanna

$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++ripJXitp4R0AKUfSnC89 x9vO
Ox39Ip6Cjvw7/TAYmZsOPKjHgL+j+aoz/hBWQBPkOScNQ3Tehc2RrpJd4f2r O+1n
Rx5YeRLFIL7kII27rFisQNH3xWk+Srgml6tsiOsYAho+fwMAGc0IYr0alwCg jQ+D
BQPpTIJSvZxJ2S2Q3e7tJB0D/0o27C6KOFcUIJKAi++DydXH7iWab/E8mLGF v0Ol
tG/XNJWBo0p00bTrj93PoJ0zTsnZamuyfstzwGX/BqLQaCqGufpxD82jHxHC 4SQC
3M3zXScYRfBeGU1ihIeQnbyH1zQeb5kq2ObmxzysBHXbTqSCE/aMEH0CxvNs GGNJ
KQrtA/4majuB0O7jdyQM3Ec182HuQ0YvWPSyxQnWq9ZLStoSbIaRckZq1wNq VMHm
kO1vS5Y4s4f5z7FaJKJh3wc2QQ/d+iMo5eDDd4a9PNZERzfKeqAJDun8HH6n 5/DD
Hu7soHugedjLQqaXYNjdPFJ0d/GPQp+AJ2gDm4K/sYUEfOCpRLQ2VW5uYXd1 dCBM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
To unsubscribe, visit: http://www.php.net/unsub.php

Re: pagination example?

am 23.11.2005 11:57:47 von Raz

Try PEAR's Pager package - fairly straightforward to use:
http://pear.php.net/package/Pager

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

Re: pagination example?

am 23.11.2005 12:15:05 von xkorakidis

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.
>>
>>
>>
>
>

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

Re: pagination example?

am 23.11.2005 12:16:38 von xkorakidis

Thanks Raz,
it looks proffesional, I'll try to take the advantage of it!
Thanks a lot!
Christos Korakidis
------------------------
Raz wrote:
> Try PEAR's Pager package - fairly straightforward to use:
> http://pear.php.net/package/Pager

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

RE: pagination example?

am 23.11.2005 13:17:15 von Bastien Koert

I posted a couple of simple function in the examples section on
www.weberdev.com

http://www.weberdev.com/get_example-4092.html
http://www.weberdev.com/get_example-4093.html

bastien


>From: xkorakidis
>To: php-db@lists.php.net
>Subject: [PHP-DB] pagination example?
>Date: Wed, 23 Nov 2005 11:51:45 +0200
>
>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.
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

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

Re: pagination example?

am 23.11.2005 14:51:04 von Unnawut Leepaisalsuwanna

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++ripJXitp4R0AKUfSnC89 x9vO
Ox39Ip6Cjvw7/TAYmZsOPKjHgL+j+aoz/hBWQBPkOScNQ3Tehc2RrpJd4f2r O+1n
Rx5YeRLFIL7kII27rFisQNH3xWk+Srgml6tsiOsYAho+fwMAGc0IYr0alwCg jQ+D
BQPpTIJSvZxJ2S2Q3e7tJB0D/0o27C6KOFcUIJKAi++DydXH7iWab/E8mLGF v0Ol
tG/XNJWBo0p00bTrj93PoJ0zTsnZam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O7quif26zN5OjnoqjfT6yWHDL PEjU
gdAsJkFDdncQEGNF5zJ7XxG1ybIMLVjvrAyvLHAsRp/G6OYurYaPIuQpHJXc LyOp
VyBVj+FmOdDoSZoomMDkMOtqris97Rw9Rm4MRNELgl4KlItMg7o3r2ca/Guf iEkE
GBECAAkFAkKI4CkCGwwACgkQey8SxD/BmXK96wCfahapDeGs55QdeyZFsWrX ejiv
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

Re: pagination example? Thanks Everybody!

am 23.11.2005 22:34:30 von xkorakidis

Thanks guys, I'll try all the documentation I and samples collected.
Thanks!
--------------------
Unnawut Leepaisalsuwanna wrote:
> 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.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

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