SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Pagination without Dynamic Content

    Does anyone know if it is possible to have a PHP pagination script when the content is not coming out of a database? Or, when the content does come out of a database, but from multiple queries as opposed to one?

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could put all the content into a text file, and add your own custom page break tag, for example [PAGE BREAK] or <--Break Page-->, where you want the page breaks to occur. You could then set up a php file to pull the contents of the text file into a variable, explode it by your custom tag and then display it on different pages.

    This may be the best way if you aren't pulling the contents out of a database. There may be a better way for you, but I'm do not know whether you have a static html page or if you are pulling the data from the database is seperate queries.

  3. #3
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I am really doing is pulling all the data out of the database in separate queries. I probably should have made that clearer. I do this because the query types are mixed.

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It shouldn't matter what the datasource is as long as it feeds the pager in a consistent way.
    PHP Code:
    $dg = new DataGateway();
    $pager = new Pager($dg);
    $pager->toHTML(); 
    Obviously oversimplified but hopefully you get the idea. If you want specifics let me know.
    Christopher

  5. #5
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So do you want each seperate query to appear on it's own page?

  6. #6
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the delay in replying. Here is an example of what I am talking about: I have 40 queries and I want 4 pages with 10 queries on each page. Let me know if I need to elaborate more.

  7. #7
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You loop through the queries then I assume?

  8. #8
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't loop through the queries because the queries are not all the same(i.e. the output is not all formatted the same way and they do not all pull from the same table). I list 10 PHP functions per page that hold 2 or 3 different types of queries.

  9. #9
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess I do not understand how you want/plan to break the content into pages then. Do you have an example I could look at?

    EDIT:

    Better yet would be to post the actual code you are using.

  10. #10
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have 40 queries and I want 4 pages with 10 queries on each page. Let me know if I need to elaborate more.

    I don't loop through the queries because the queries are not all the same(i.e. the output is not all formatted the same way and they do not all pull from the same table). I list 10 PHP functions per page that hold 2 or 3 different types of queries.
    I think we would need to see examples of these queries to understand what you are trying to do and present possible solutions.
    Christopher

  11. #11
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if I haven't explained it well. I know this seems like a weird way to do it, but a typical page would look something like:

    <?php query_function_1(41); ?>
    <?php query_function_3(8); ?>
    <?php query_function_1(485) ; ?>
    <?php query_function_2(515); ?>
    <?php query_function_1(31); ?>
    <?php query_function_3(222); ?>
    <?php query_function_2(410); ?>
    <?php query_function_2(6); ?>
    <?php query_function_1(39); ?>
    <?php query_function_3(188); ?>

    Each function does a database query based on the id number that is passed to it and then writes some HTML to format the result.

  12. #12
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Creating a paging system with this methodology might be a bit tricky, especially since each independent function writes html.

    You might want to consider chaning the functions so that they return arrays instead of writing html. Then after each function is run you could combine the arrays, pull out the 10 that you want, format them and then write them.

    Hope this helps.

  13. #13
    SitePoint Addict frankiehots's Avatar
    Join Date
    Jan 2002
    Location
    U.S.A. *Blue State*
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's what I thought. I know the easier way would be to just set up a pagination script to work off of one query that would pull many products. The only reason I am trying to do it this way is the site owner requires things to be layed out in a somewhat inconsistent way.


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
  •