pagination now works

git-svn-id: http://yolanda.mister-muffin.de/svn@147 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-10-28 03:06:01 +00:00
parent 74b06d05bb
commit d8aa4854e9
2 changed files with 12 additions and 10 deletions

View file

@ -83,15 +83,15 @@ if($username)
#execute it #execute it
$resultcount = $sth->execute($session->id, $session->id) or die $dbh->errstr; $resultcount = $sth->execute($session->id, $session->id) or die $dbh->errstr;
$rowsperpage = 2; $pagesize = 2;
#rediculous but funny round up, will fail with 1000000000000000 results per page #rediculous but funny round up, will fail with 100000000000000 results per page
#on 0.00000000000001% of all queries - this is a risk we can handle #on 0.0000000000001% of all queries - this is a risk we can handle
$lastpage = int($resultcount/$rowsperpage+0.999999999999999); $lastpage = int($resultcount/$pagesize+0.99999999999999);
$currentpage = $query->param('page') or $currentpage = 1; $currentpage = $query->param('page') or $currentpage = 1;
$dbquery .= " limit ".($currentpage-1)*$rowsperpage.", ".$rowsperpage; $dbquery .= " limit ".($currentpage-1)*$pagesize.", ".$pagesize;
#prepare query #prepare query
$sth = $dbh->prepare($dbquery) or die $dbh->errstr; $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
@ -102,6 +102,7 @@ if($username)
$page->{'results'}->{'lastpage'} = $lastpage; $page->{'results'}->{'lastpage'} = $lastpage;
$page->{'results'}->{'currentpage'} = $currentpage; $page->{'results'}->{'currentpage'} = $currentpage;
$page->{'results'}->{'resultcount'} = $resultcount; $page->{'results'}->{'resultcount'} = $resultcount;
$page->{'results'}->{'pagesize'} = $pagesize;
#get every returned value #get every returned value
while (my ($id, $title, $publisher, $timestamp, $duration, $viewcount) = $sth->fetchrow_array()) while (my ($id, $title, $publisher, $timestamp, $duration, $viewcount) = $sth->fetchrow_array())

View file

@ -93,15 +93,15 @@ if($query->param('query') or $query->param('orderby'))
#execute it #execute it
$resultcount = $sth->execute(@args) or die $dbh->errstr; $resultcount = $sth->execute(@args) or die $dbh->errstr;
$rowsperpage = 2; $pagesize = $query->param('pagesize') or $pagesize = 5;
#rediculous but funny round up, will fail with 1000000000000000 results per page #rediculous but funny round up, will fail with 100000000000000 results per page
#on 0.00000000000001% of all queries - this is a risk we can handle #on 0.0000000000001% of all queries - this is a risk we can handle
$lastpage = int($resultcount/$rowsperpage+0.999999999999999); $lastpage = int($resultcount/$pagesize+0.99999999999999);
$currentpage = $query->param('page') or $currentpage = 1; $currentpage = $query->param('page') or $currentpage = 1;
$dbquery .= " limit ".($currentpage-1)*$rowsperpage.", ".$rowsperpage; $dbquery .= " limit ".($currentpage-1)*$pagesize.", ".$pagesize;
#prepare query #prepare query
$sth = $dbh->prepare($dbquery) or die $dbh->errstr; $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
@ -112,6 +112,7 @@ if($query->param('query') or $query->param('orderby'))
$page->{'results'}->{'lastpage'} = $lastpage; $page->{'results'}->{'lastpage'} = $lastpage;
$page->{'results'}->{'currentpage'} = $currentpage; $page->{'results'}->{'currentpage'} = $currentpage;
$page->{'results'}->{'resultcount'} = $resultcount; $page->{'results'}->{'resultcount'} = $resultcount;
$page->{'results'}->{'pagesize'} = $pagesize;
#get every returned value #get every returned value
while (my ($id, $title, $creator, $description, $publisher, $timestamp, $duration, $viewcount, $relevance) = $sth->fetchrow_array()) while (my ($id, $title, $creator, $description, $publisher, $timestamp, $duration, $viewcount, $relevance) = $sth->fetchrow_array())