Hi there, I’ve been trying to implement pagination to an existing script that displays products, but at present only displays next and back buttons. The number of products is now increasing and we would like to show the number of pages of results but the tutorials I’ve been going through seem to use a very different way of displaying the results to the script we currently have. Does anyone have any suggestions how I could add pagination to this form…
// Build Pagination
$ByPage = ($prod_rows * $prod_cols);
$qnav = "SELECT devbg_products., devbg_categories., devbg_subcategories.* FROM devbg_products
LEFT JOIN devbg_categories ON devbg_products.ItemCategory = devbg_categories.CategoryID
LEFT JOIN devbg_subcategories ON devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID
WHERE devbg_products.ItemCategory = " . sql($cgid);
$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);
if($rows > $ByPage)
{
$pages = ceil ($rows / $ByPage);
echo "<br>\n";
echo "<table align='center'>\n";
echo "<tr>\n";
echo "<td align=center><font face=verdana size=2>";
echo "<form method='POST' action='ShowCategory.php'>\n";
echo "<input type='hidden' name='Start' value='" . ($Start - $ByPage) . "'>\n";
echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n";
echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n";
if (($Start - $ByPage) <> -$ByPage)
{
echo "<input class='sub' type='submit' value='<<< Back' name='btnBack'>\n";
echo "</form>\n";
echo "</td>\n";
}
echo "<td>\n";
echo "<form method='POST' action='ShowCategory.php'>\n";
echo "<input type='hidden' name='Start' value='" . ($Start + $ByPage) . "'>\n";
echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n";
echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n";
if ($Start + $ByPage < $pages * $ByPage)
{
echo "<input class='sub' type='submit' value='Next >>>' name='btnNext'>";
}
echo "</form>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table><br><br>\n";
}