Jump to content

judda

Administrators
  • Posts

    354
  • Joined

  • Last visited

  • Days Won

    44

Posts posted by judda

  1. 4 hours ago, Aminirus said:

    Things are going alright in that department here at least. It seems to have slowed down in our town and places are starting to open back up bit by bit, but just still required to wear a mask and most sit down restaurants are still closed, which is fine.

    How about you?

    About the same here - a few weeks ago my city was deemed a "hot bed" but I haven't heard much of that lately (thankfully).  Apparently Ontario is talking about opening up offices starting July 1st.  I hope we don't go back that early.  I see everyone daily on zoom calls, so don't feel the need.  That being said - I'm off for a week and a bit at that point ? so I'm less worried.

    I found out this past week that my cousin had lost their job for covid which sucks :( hopefully this sparks a re-entrance into work for him too.

  2. 15 hours ago, Hare said:

    How many things on the page:
     

    
    $perpage = 100;

    Then put this after to get the page number from the URL
     

    
    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
    $start_from = ($page-1) * $perpage; 

    This add this to the end of the select query of things youre paginating.
     

    
    LIMIT $start_from, $perpage

    Then you just need to gather the links to the pages (in another query but without the limit). 

    You have to be careful with a query like that.  You should be validating that it is more than just set otherwise you could potentially get yourself into SQL injection territories. Adding in an "intval" could help with that just to 100% make the string an integer before being placed in your code.

    I've adjusted your code block to also remove the "else" section, because you can easily define it above, and won't run into scoping issues.

    $page = 1;
    
    if (isset($_GET["page"]) && ($value = intval($_GET["page"]))) {
        $page  = $value;
    }
    
    $start_from = ($page-1) * $perpage; 

    The caveat with this code, is it isn't going to do a "0-based", so your pages must start at 1 which is what you are doing anyways with the page - 1 part.

    • Like 1
×
×
  • Create New...