By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

Pagination

P: n/a
Anyone know of a up-to-date tutorial for pagination where I can have it
like:

Prev 1 2 3 4 Next

Thanks.
--
Sharif T. Karim
....you don't know wrath yet...
Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Sharif T. Karim wrote:
Anyone know of a up-to-date tutorial for pagination where I can have it
like:

Prev 1 2 3 4 Next

Thanks.


if you go to google, groups, comp.languages.php and search for
pagination, there was a recent discussion on this topic...

<<
http://groups.google.com/groups?hl=e...hp&btnG=Search


Michael Austin.
Jul 17 '05 #2

P: n/a
Try this for size: http://www.tonymarston.co.uk/php-mysql/pagination.html

--
Tony Marston

http://www.tonymarston.net
"Sharif T. Karim" <sh****@nyc.rr.com> wrote in message
news:Sc******************@twister.nyc.rr.com...
Anyone know of a up-to-date tutorial for pagination where I can have it
like:

Prev 1 2 3 4 Next

Thanks.
--
Sharif T. Karim
...you don't know wrath yet...

Jul 17 '05 #3

P: n/a
"Sharif T. Karim" <sh****@nyc.rr.com> wrote in message news:<Sc******************@twister.nyc.rr.com>...
Anyone know of a up-to-date tutorial for pagination where I can have it
like:

Prev 1 2 3 4 Next

Thanks.


My concept of pagination, if it helps, is to perform the following
steps:

1) One single DB call to grab everything at one time that you need to
list
2) Store entire contents of the resultset into a $_SESSION variable
(serialized, of course)
3) Establish a $prev and $next routine with integer values that limit
the amount of display per page and calculate your $prev and $next
4) Upon each click of your "Previous" and "Next" links you will pull
not from the DB but from the serialized $_SESSION variable to ensure
efficiency and data reusability
5) Filter results by $prev and $next to only display the results you
need per page
6) Also allow for a "view all" link if the user wants to see
everything at one time
7) *Important* When you go to view another set of stuff, be sure to
"flush" the cache by destroying the $_SESSION variable to ensure not
having latent results floating around in your $_SESSION cache.

My $0.02

Phil
Jul 17 '05 #4

P: n/a
I noticed that Message-ID:
<1c**************************@posting.google.com > from Phil Powell
contained the following:
4) Upon each click of your "Previous" and "Next" links you will pull
not from the DB but from the serialized $_SESSION variable to ensure
efficiency and data reusability


And /is/ that more efficient than separate DB queries?

Curious to know.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

P: n/a
Hi,

You could take a look at:
http://www.phppeanuts.org/site/index...bjectIndexPage
It produces a paged display of instances of a peanuts domain model class
(peanuts) that are loaded from all records from a table.

Building the list of paging buttons is done by a seperate component:
http://www.phppeanuts.org/site/index...stBuilder.html

The acual output of buttons is done by instances of PntButtonsPart and
PntButtonsPanel and the html table by PntTablePart, for code see:
http://www.phppeanuts.org/site/index...rts/parts.html

For a subclass that does searching in the database see:
http://www.phppeanuts.org/site/index...jectSearchPage
It uses a specialized part for generating and processing the search form:
http://www.phppeanuts.org/site/index...FilterFormPart

Or you could simply download the framework and use it,
example:
http://www.phppeanuts.org/examples/e...ler=SearchPage
Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

Sharif T. Karim wrote:
Anyone know of a up-to-date tutorial for pagination where I can have it
like:

Prev 1 2 3 4 Next

Thanks.


Jul 17 '05 #6

P: n/a
Tony Marston, being the foo Tony Marston is, wrote:
Try this for size:
http://www.tonymarston.co.uk/php-mysql/pagination.html


Thanks a lot Tony.

--
Sharif T. Karim
....you don't know wrath yet...
Jul 17 '05 #7

P: n/a
In message-id <pk********************************@4ax.com>,
Geoff Berrow wrote:
I noticed that Message-ID:
<1c**************************@posting.google.co m> from Phil Powell
contained the following:
4) Upon each click of your "Previous" and "Next" links you will pull
not from the DB but from the serialized $_SESSION variable to ensure
efficiency and data reusability


And /is/ that more efficient than separate DB queries?

Curious to know.


dunno about efficiency, but i can certainly see an advantage where the
data being retrieved is constantly changing - above approach provides
the user session with a 'snapshot' of the database a a specific moment
in time.

of course, with many users and large data sets this would become a
major problem, because you'd be creating a new 'copy' of the data for
every user session, which would need to be stored on disk.

hc.

Jul 17 '05 #8

P: n/a
Geoff Berrow <bl******@ckdog.co.uk> wrote in message news:<pk********************************@4ax.com>. ..
I noticed that Message-ID:
<1c**************************@posting.google.com > from Phil Powell
contained the following:
4) Upon each click of your "Previous" and "Next" links you will pull
not from the DB but from the serialized $_SESSION variable to ensure
efficiency and data reusability


And /is/ that more efficient than separate DB queries?

Curious to know.


For what I wrote, very much so, yes! Using timing techniques on
pages, the initial run of a listing query took the page download time
to average 1.5 - 2.0 seconds. Upon clicking "Next" (and then
subsequently clicking "Prev" or whatever) each page download time
decreased significantly, going to 0.1 - 0.5 seconds per iteration,
since it was delivering from $_SESSION instead of db query.

Phil
Jul 17 '05 #9

P: n/a
Herbie Cumberland <no**********@non-existant.tld> wrote in message news:<42********************************@4ax.com>. ..
In message-id <pk********************************@4ax.com>,
Geoff Berrow wrote:
I noticed that Message-ID:
<1c**************************@posting.google.co m> from Phil Powell
contained the following:
4) Upon each click of your "Previous" and "Next" links you will pull
not from the DB but from the serialized $_SESSION variable to ensure
efficiency and data reusability
And /is/ that more efficient than separate DB queries?

Curious to know.


dunno about efficiency, but i can certainly see an advantage where the
data being retrieved is constantly changing - above approach provides
the user session with a 'snapshot' of the database a a specific moment
in time.

of course, with many users and large data sets this would become a
major problem, because you'd be creating a new 'copy' of the data for
every user session, which would need to be stored on disk.


Ay and there's the advantage of what I built being that it's a
single-user internal application, that would mean only one 'copy'
would exist since there would be only one user session stored on disk.

Phil


hc.

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.