Changeset 35224 for trunk/www


Ignore:
Timestamp:
Mar 21, 2008, 6:09:31 AM (12 years ago)
Author:
eridius@…
Message:

Page numbers should start at 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/ports.php

    r35223 r35224  
    2121    $by = isset($_GET['by']) ? $_GET['by'] : '';
    2222    $substr = isset($_GET['substr']) ? $_GET['substr'] : '';
    23     $page = isset($_GET['page']) ? max($_GET['page'], 0) : '';
    24     $pagesize = isset($_GET['pagesize']) ? max($_GET['pagesize'], 0) : 50; # arbitrary setting
     23    $page = isset($_GET['page']) ? max($_GET['page'], 1) : '1';
     24    $pagesize = isset($_GET['pagesize']) ? max($_GET['pagesize'], 1) : 50; # arbitrary setting
    2525
    2626    print_header('The MacPorts Project -- Available Ports', 'utf-8');
     
    122122        $query = "SELECT DISTINCT $fields FROM $tables $where ORDER BY name";
    123123        if ($paging) {
    124             $offset = $pagesize * $page;
     124            $offset = $pagesize * ($page-1);
    125125            $query .= " LIMIT $pagesize OFFSET $offset";
    126126            # get the total count
     
    132132            # generate a paging control and cache it so we can show it twice
    133133            $pagecontrol = "<p>Page ";
    134             for ($i = 0; $i < $pagecount; $i++) {
    135                 if ($i != 0) {
     134            for ($i = 1; $i <= $pagecount; $i++) {
     135                if ($i != 1) {
    136136                    $pagecontrol .= " | ";
    137137                }
Note: See TracChangeset for help on using the changeset viewer.