Pagination and DB question
Moderator: General Moderators
Pagination and DB question
I use some kind of a class for pagination of my results which is "called" this way:
$mysql = mysql_query("SOME QUERY", 10);
number 10 is the number of reccords thatI want to display per page.
My question is:
With pagination of the results - is the DB (mysql) every time accessed when you hit next page > or page 3, 4 or so.... or are the results some how cached on the client side - so that my DB is queried only once - at the initial query.
Anyone ?
$mysql = mysql_query("SOME QUERY", 10);
number 10 is the number of reccords thatI want to display per page.
My question is:
With pagination of the results - is the DB (mysql) every time accessed when you hit next page > or page 3, 4 or so.... or are the results some how cached on the client side - so that my DB is queried only once - at the initial query.
Anyone ?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
you could create your own javascript objects that store the data then have your next, prev page numbers go and get the right data and do lots of innerHTML setttings to redisplay the new data. Other wise you will have to keep round tripping to the db with the new resutls and as Phenom said use the limit clause in mysql limit $startAtResult, $returnHowMany.
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
very true, i used this methof and was getting parse times of circa 40 seconds on a 100k item database, it is not an option for large sitesphpScott wrote:i agree timvw but it is an option that if you didn't want to keep roundtripping to the server you could do, i wouldn't recomened it for medium to large sites as the intial download could be very large and time consuming.
phpScott
...
Ok, me need to clarify this to me self.
If I decide to use sessions or cookies or JS or any client side "technique", can this be done in my example - I limit my qurey results to 100 inside the MySQL statement.
So my question is - can any of these 3 techniques be used in this example - to store data on the client side and paginate it there.
And I didn't quite get the point of the "very big sites - time consuming...".
What point am I missing!?!?
If I decide to use sessions or cookies or JS or any client side "technique", can this be done in my example - I limit my qurey results to 100 inside the MySQL statement.
So my question is - can any of these 3 techniques be used in this example - to store data on the client side and paginate it there.
And I didn't quite get the point of the "very big sites - time consuming...".
What point am I missing!?!?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I'd generally suggest not storing the information client-side:So my question is - can any of these 3 techniques be used in this example - to store data on the client side and paginate it there.
And I didn't quite get the point of the "very big sites - time consuming...".
What point am I missing!?!?
- it can change while they are looking at it.
- it'll take the browser a while to load a large page, since you'll have to send a LOT of data to the browser to create all the client-side scripting needed
- The client-side scripting could easily be turned off, and result in functionality breakdown