AJAX + PHP Pagination Table

Discussion in 'PHP' started by PET, Jul 30, 2008.

  1. #1
    Hello,

    I pull the info from the database with a query, then I have a table to show the information. I found several PHP tutorials on how to make some page numbers :

    << PREV 1 - 2 - 3 -4 NEXT >>

    (in case you don't know what I mean)

    and I can do that. It dosn't seem so hard. However I was thinking on doing it the AJAX way.

    I tried to do a google search, however I don't know for what to search exactly.

    --------

    Normaly from what I'm thinking, when the page is loaded and I query the info, I will build the pages normaly. But the link from the pages must be done JavaScript style. I'm trying to understand the normal process on how to do this, but ... 1. Think that I have to make a function that sends the requied page to the PHP, then the PHP has to send back the new info and display it, updating the link (from the address bar) and also changing the page links (if i'm on the page 2, and I go to page 3, page 3 should not be marked as a link)...

    So any sugestions?

    Thanks
     
    PET, Jul 30, 2008 IP
  2. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I don't think that you can achieve this. As far as I know, you can't change or refresh the main page with AJAX.
     
    php-lover, Jul 30, 2008 IP
  3. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I'v seen this going on.

    You click on the new page. A "small window" appears telling about the "loading...", the link from the address bar chagnes and the new table is populated.

    The link to the new page is:

    javascript://browse.php?orderby=added&page=3

    I'm trying to figure what function it's calling.
     
    PET, Jul 30, 2008 IP
  4. Typo3 Steve

    Typo3 Steve Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can do it easily... Its quite easy actually.

    I recommend you to use mootools for the javascript part... have a look at this: http://demos.mootools.net/Request.HTML#

    Basically, you query your server, by sending GET parameters. For example: http://www.yourdomain.com/index.php?begin=5&amount=10 .

    Then, in your php script, you make the SQL query necessary to get your data, show it in html, and the Request.HTML object, in javascript will take that html content and add it inside any container of your DOM.(For example, a div element).

    It takes around 20 minutes to write that... if you cant write it, PM me and I willwrite it for you.

    Steve
     
    Typo3 Steve, Jul 31, 2008 IP
  5. rob_v

    rob_v Peon

    Messages:
    72
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    rob_v, Jul 31, 2008 IP
  6. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #6
    PAT search for php classes . are a lot of classes for pagination
    phpclasses.org
     
    CarcaBot, Jul 31, 2008 IP
  7. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #7
    Wow. This looks very interesting. I'm curious about the page loating time and how this will work.
     
    PET, Jul 31, 2008 IP
  8. rob_v

    rob_v Peon

    Messages:
    72
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have several tables that I load 500+ records into them - load time is fine - sort time is great.
    Its one of the best ones out there that I have seen.
    Some one tried to do something like it in MooTools - but the speed just wasnt / isnt there.
     
    rob_v, Aug 1, 2008 IP
  9. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #9
    Now I have about 200 enytries and it tages about 5 seconds to load on my localhost, that's why i'm curious on how this script manages to hide and then filter/sort the products.
     
    PET, Aug 1, 2008 IP
  10. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #10
    I'm looking and looking at that javascript table and I can't figure it out. Basicly there is no documentation on how to start with it.

    Later Edit:

    Hmm... I manage to show the table. Only 25 rows (but I can change that). Then I also have the links that change the "page" of the table.

    However it still takes a long time to load, because I have about 150 total rows and I will have more. So I will still have to limit the query to 25 rows. Then when a new page is pushed, I will try to modify the "page javascript function" to get the new query and display it in the table.

    Soooo... I manage to play with the table. Great stuff there, however I also have to limit my query so the page will load faster :(
     
    PET, Aug 1, 2008 IP
  11. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    koolman, Aug 8, 2008 IP