Need a code snippet for backward paging...

Posted by Ali on Stack Overflow See other posts from Stack Overflow or by Ali
Published on 2010-05-26T12:57:36Z Indexed on 2010/05/26 14:01 UTC
Read the original article Hit count: 356

Filed under:
|

Hi guys I'm in a bit on a fix here. I know how easy it is to build simple pagination links for dynamic pages whereby you can navigate between partial sets of records from sql queries. However the situation I have is as below:

COnsider that I wish to paginate between records listed in a flat file - I have no problem with the retrieval and even the pagination assuming that the flat file is a csv file with the first field as an id and new reocrds on new lines.

However I need to make a pagination system which paginates backwards i.e I want the LAST entry in the file to appear as the first as so forth. Since I don't have the power of sql to help me here I'm kinda stuck - all I have is a fixed sequence which needs to be paginated, also note that the id mentioned as first field is not necessarily numeric so forget about sorting by numerics here.

I basically need a way to loop through the file but backwards and paginate it as such.

How can I do that - I'm working in php - I just need the code to loop through and paginate i.e how to tell which is the offset and which is the current page etc.

© Stack Overflow or respective owner

Related posts about php

Related posts about pagination