Hello
I'm using a pagination script by matt from codewalkers and i've modified it a bit trying to get total number of pages and page you're currently viewing to show.
It works fairly good but I do believe the math is a bit wrong. Every now and again, the script tells me i'm on page 1 of 4 or something like this, and i click next page, it shows page 2, and tells me i'm on 1 of 4 still.
Sometimes it works perfectly ( such as when I show an even number of rows per page ) but not always.
I'm really confused and I'm terrible at math! I'm hoping I can get a little bit of help with this, here it is:
<?php
$tagsToDisplay = "24"; // The number of tags you want to show your users per page. (15-30 suggested)
if(!isset($tags)) $tags = "0";
$query = "SELECT * FROM tagit ORDER BY id DESC LIMIT " . $tags . ", " . $tagsToDisplay . " ";
$result = mysql_query($query); // Add error checking
$rowcount = mysql_num_rows($result);
echo "\n<!-- There are $rowcount tags to display -->\n";
/* Next Prev Links */
echo "<div align=\"center\">";
$query = "SELECT count(*) as count FROM tagit";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numRows = $row['count'];
$pageNums = ceil ($numRows/$tagsToDisplay);
if($tags == "0") { $PageNowViewing = "1"; }
else{
$PageNowViewing = ceil ($tags*$pageNums/$numRows);
}
if($tags > 0) {
echo "<a href=\"" . $PHP_SELF . "?tags=" . ($tags - $tagsToDisplay) .
"\" class=\"navLink\"><<</a> ";
}
echo "<span class=\"formtext\">Page $PageNowViewing of $pageNums</span> ";
if($numRows > ($tags + $tagsToDisplay)) {
echo "<a href=\"" . $PHP_SELF . "?tags=" . ($tags + $tagsToDisplay) .
"\" class=\"navLink\">>></a>";
}
?>
Essentially, thats the entire modified script that i'm using. Any help on this would be greatly appreciated!