Pagination Problem


#1

Currently building a pagination class and i´m having a tiny problem. The first page looks fine but when i go to page 2 the rows has the same data -1 row from the top. (FaaPz/Slim-PDO)

Get users

        $stmt  		= $this->pdo->select()->from($this->table);
        $currPage   = /* GET */;
        
        $limit  = 5;
        $offset = $limit;
        $row 	= $limit;

        if ($currPage == 1) {
                    $offset = $limit ;
                    $row 	= 0;
        }else{
                    $offset = ($offset * $currPage);
                    $row 	= ($row * $currPage - $limit );
        }

        $stmt  		= $stmt->limit( (int)$offset , (int)$row );
        $stmt  		= $stmt->execute();
        $data  		= $stmt->fetchall();


Still buggy


#2

I´m always to fast with posting my problems, heres my solution

$stmt  		= $this->pdo->select()->from($this->table);
$currPage   = /* GET*/;
$limit  = 3;
$offset = $limit;
$row 	= $limit;

if ($currPage == 1) {
    $stmt  		= $stmt->limit( $limit , 0 );
}else{
    $row 	= ($row * $currPage) - $limit;
    $stmt  		= $stmt->limit( (int)$limit , (int)$row );
}

$stmt  		= $stmt->execute();
$data  		= $stmt->fetchall();