PHP Scripting Forums » PHP Classes Support Forum » MyPagina class Support forum

Change number of items per page MyPagina

(6 posts)
  • Started 7 months ago by telconstar99
  • Latest reply from Olaf
Please support us by buying these products:

  1. User has not uploaded an avatar

    telconstar99
    Member

    Hello,

    I'm using the MyPagina class. I'd like to change the number of items per page I'm displaying. Right now I am simply displaying the default 4 items per page.

    This is what my code looks like:

    $myGallery = new MyPagina;
    $myGallery->sql = "SELECT * FROM galleries WHERE category LIKE '%".$category."%' ORDER BY date DESC";
    $result = $myGallery->get_page_result();
    $myGallery->rows_on_page=6;
    $num_rows = $myGallery->get_page_num_rows();
    $nav_links = $myGallery->navigation(" | ", "currentStyle");
    $nav_info = $myGallery->page_info("to");
    $simple_nav_links = $myGallery->back_forward_link();
    $total_recs = $myGallery->get_total_rows();
    
    $p=0;
    while($p<$myGallery->rows_on_page)
    {
    $row = mysql_fetch_row($result);
    $p++;
    //Display my item
    }

    However, while it does go through the while loop 6 times, it does not retrieve 6 items. It only retrieves 4. But changing the below line will affect the number of pagination links displayed (the forward and back links).

    $myGallery->rows_on_page=6;

    So, how can I get my page to display all 6 of the items I want it to display? I have the pagination links displaying properly.

    TIA.

    Posted 7 months ago #
  2. Hi,

    try
    $myGallery = new MyPagina(4);

    Posted 7 months ago #
  3. User has not uploaded an avatar

    telconstar99
    Member

    I tried the following, it seemed to have no effect:

    $myGallery = new MyPagina(4);

    or

    $myGallery = new MyPagina(6);

    Posted 7 months ago #
  4. sorry, that was the total limit of records for your result.

    check the config file for:

    define("NUM_ROWS", 5); // the number of records on each page

    Posted 7 months ago #
  5. User has not uploaded an avatar

    telconstar99
    Member

    Yup, that works.

    However, that fixes all my instances of the pagination class to that number. So I played around with it some more and apparently I had all the correct code in there but I you have to have this statement pretty early:

    $myGallery->rows_on_page=10;

    So once you have that in pretty early it seems to work. Thanks for your help.

    Posted 7 months ago #
  6. yes right, if you use that class for multiple instances, this constant variable is not very useful. Your solution is the best you can do...

    Posted 7 months ago #

RSS feed for this topic

Reply

You must log in to post.