SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    555
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to create pagination of an array

    Hi,

    I am retriving records from db and they are stored in an array before display to user because there arr 3 different sql statements which retrieve the data.

    So i have stored the results in the array so i can create pagination through array. Can anyone tell me how do i create pagination using array ?

    Thanks.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Devon, UK
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to paginate using a page refresh then it's easy - just pass page=N to your script, display the appropriate array indexes, then link to page=N+1 (next page) and page=N-1 (previous page). Obviously, your script will execute the SQL every time the user moves to a different page.

    An alternative would be to put the whole array onto the page (as a table or whatever), then paginate using DOM scripting. That's an efficient method, but would only be realistic if you don't have too thousands of data items.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •