Jump to content

Keeping track of result


jorx2

Recommended Posts

As most of all php-application I want to show the user a result from a db-query. But how do I divide the result in many pages, making it possible to specify page number in the query string? Of course I can run mysql_db_query() and fetch rows 20 times to show page 2 but this seems a little bit akward. And what will happen if a row from the db table is removed. When the user clicks next, the first row in that page has suddenly been moved to page 1 if one of the rows at page 1 is removed.

Link to comment
https://forums.phpfreaks.com/topic/192412-keeping-track-of-result/
Share on other sites

What you want ot do is called pagination. You can google for it, here's the first result I found: http://www.tonymarston.net/php-mysql/pagination.html

 

Re: record being removed while viewing - you said "if one record gets removed it will move the records up the list and you might miss seeing one record". that would actually depend on _which_ record gets removed. If you removed a record from a page previous to the one you are viewing it would do this. If you removed one on a page after the one you are viewing it would not. I think this is one of the things a multiuser environment is going to introduce and there's not much you can do about it besides loading the results into an array/some other local format and then paging through those results rather than sending queries to the DB upon each page load. But then, your user is not getting the most current version of the results so it would depend on what your task is to decide if that's approprate or not.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.