Page 1 of 1

Paging function/navigation (running through an array)

Posted: Tue May 24, 2005 12:10 pm
by visionmaster
Hello together,

At the moment (actually the whole day) I'm having problems impementing a paging fuction. For most of you this problem may be trivial to you, but I really can't get it to work to my satisfaction. I guess I'm thinking way to complicated... :-(

I'm doing a search and save alle found results in a session-array. So I run through a array. Now I would like to provide a paging function (navigation). Only 10 pages at a time should be displayed in my paging navigation. Of course a search query may give back less than 10 results.

Furthermore the user is able to choose how man results should be displayed pro page, 10 results, 20 results or 30 results:

[1] 2 3 4 5 6 7 8 9 10 >> next

A click on >> next goes to page 2:

<< previous 1 [2] 3 4 5 6 7 8 9 10 >> next

So >> next goes to the next page forward
So << back goes to the previous page back


Now suppose I'm on page 10 an click >> next

<< previous 1 2 3 4 5 6 7 8 9 [10] >> next

Since I just want to display a maximum of 10 pages in my navigation, the pages should shift 1 to the right, like this:

<< previous 2 3 4 5 6 7 8 9 11 [12] >> next

(Particularly the shifting function is giving me a headache...)

Another click on >> next :

<< previous 3 4 5 6 7 8 9 11 12 [13] >> next

(Previous should work the same, just backwards.)

Last but not least, one should be able to directly click on a number.

Thanks for your patience and help!

Posted: Sat May 28, 2005 4:47 am
by JAM
Please do a search on pagination first, then let us know if that didn't help you out. One of the most common questions that have been discussed very often.