pagination with a sorted array
Posted: Fri Nov 09, 2007 10:35 am
I am having a small problem with my pagination.
I create a sorted array with about 5 elements and they are sorted by closest distance. It works fine until I add pagination. For some reason the first page works great until I go to the next one. The algorithm to find the distance is messed up meaning the last element of distance on the previous page is not even related to the first element of distance on the next page.
I have tried a number of pagination including looking at ajax a few times.
My question is this. Instead of querying the database each time for each page, I want to create the array and sort it and use it instead of the mysql query. The problem then arises on how to code it to work with the array rather than the query.
The array is a 2d array by the way.
Any help would be greatly appreciated.
I create a sorted array with about 5 elements and they are sorted by closest distance. It works fine until I add pagination. For some reason the first page works great until I go to the next one. The algorithm to find the distance is messed up meaning the last element of distance on the previous page is not even related to the first element of distance on the next page.
I have tried a number of pagination including looking at ajax a few times.
My question is this. Instead of querying the database each time for each page, I want to create the array and sort it and use it instead of the mysql query. The problem then arises on how to code it to work with the array rather than the query.
The array is a 2d array by the way.
Any help would be greatly appreciated.