Previous and Next code problem
Posted: Wed Jul 27, 2005 5:10 pm
Hi there.
I have the following code:
then the Select query ending with
and the Previous and Next codes:
Everything works except for the Next link which always appears even if there are no more rows to show
for example if there are only 10 rows in the database table and my limit is to show 10 rows per page the Next link will still show which i don't want it to.
Can anybody see a problem with the above code that could be causing this problem?
Any help would me greatly appreciated.
Thanks in advance
Ross
I have the following code:
Code: Select all
$totalrows = $fcount[friends];
$limit = 10;
if(!$page){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);Code: Select all
LIMIT $limitvalue,$limit"Code: Select all
if($page != "1"){
$pageprev = $page - 1;
echo "[<a href='test.php?page=$pageprev'>Previous</a>]";
}
$numofpages = $totalrows / $limit;
$numofpages = ceil($numofpages);
for($j = 1; $j <= $numofpages; $j++) {
if($j == $page){
echo "[$page]";
}
else{
echo "[<a href='test.php?page=$j'>$j</a>]";
}
}
if(($totalrows = ($limit * $page)) > 0){
$pagenext = $page + 1;
echo "[<a href='test.php?page=$pagenext'>Next</a>]";
}for example if there are only 10 rows in the database table and my limit is to show 10 rows per page the Next link will still show which i don't want it to.
Can anybody see a problem with the above code that could be causing this problem?
Any help would me greatly appreciated.
Thanks in advance
Ross