I have this code on my site and it works fine. You may have to change it some to fit your needs. Have fun scramblin through🙂
See it in action:
https://www2.serve.com/ttt/php/store.php?categoryID=8&categoryName=African%20American¤t=1
[/code]
<?
print("<font size=\"4\" color=\"#FF0000\">OUT OF STOCK</font> <b>Items will be available for shipping in 2 - 6 weeks from order date. Your account will NOT be charged for any items ordered that are </b><font size=\"4\" color=\"#FF0000\">OUT OF STOCK</font><b> until they come in.</b><br>");
$limit=10; // rows to return
$numresults=mysql_query("select * from storeProduct where storeProduct.productCategory = '$categoryID' order by productName");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=0;
}
$query = "select * from storeProduct where storeProduct.productCategory = '$categoryID' order by productName limit $offset, $limit";
$mysql_result = mysql_query($query, $mysql_link);
$num_rows = mysql_num_rows($mysql_result);
printf("<font color=\"#24377E\" size=\"6\">%s</font><font color=\"#24377E\"><br>\n", $categoryName);
echo "<b>$numrows Items</b></font><br>";
if ($offset==0) { // bypass PREV link if offset is 0
print(" ");
}
else
{
$prevoffset=$offset-10;
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s&i=%s\">PREV</a> \n", $categoryID, $categoryName, $prevoffset, $current-1, $i-1);
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
if($current==$i)
{
print("<font size=\"5\" color=\"#FF0000\"><b>$i </font></b>");
}
else
{
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s\">$i</a> \n", $categoryID, $categoryName, $newoffset, $i);
}
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
$newoffset=$offset+$limit;
}
if($newoffset >= $numrows)
{
print(" ");
}
else
{
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s&i=%s\">NEXT</a><p>", $categoryID, $categoryName, $newoffset, $current+1, $i+1);
}
print("<table width=\"500\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"3\">");
print("<tr><td align=\"center\" width=\"70\"><b>Order</b></td>
<td align=\"center\" width=\"90\"><b>Image</b></td><td align=\"center\" width=\"150\"><b>Description</b></td>
<td align=\"center\" width=\"63\"><b>Price</b></td><td align=\"center\" width=\"63\"><b>Case Price</b></td><td align=\"center\" width=\"63\"><b>Case Pack</b><td></tr>");
print("</table>");
while($row = mysql_fetch_row($mysql_result))
{
print("<table width=\"500\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"3\">");
print("<tr>\n");
printf("<td width=\"70\" valign=\"center\" align=\"center\"><a href=\"store.php?categoryID=%s&categoryName=%s&productID=%s\"><img src =\"https://www2.serve.com/ttt/pf/order.gif\" border=\"0\"></a><font size=\"1\" color=\"#0000FF\"> see more info...</font></td><td width=\"90\" align=\"center\"><img border=\"0\" src=\"https://www2.serve.com/ttt/pic/%s\" width=\"85\" height=\"85\"></td>\n", $row[2], $categoryName, $row[0], $row[4]);
printf("<td alidn=\"center\" width=\"150\"><b>%s</b> %s</td>", $row[1], $row[3]);
printf("<td align=\"center\" width=\"63\">%s</td>", $row[5]);
printf("<td align=\"center\" width=\"63\">%s</td>", $row[7]);
printf("<td align=\"center\" width=\"63\">%s</td>", $row[8]);
print("</tr>");
print("</table>\n");
print("<hr>\n");
}
if ($offset==0) { // bypass PREV link if offset is 0
print(" ");
}
else
{
$prevoffset=$offset-10;
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s&i=%s\">PREV</a> \n", $categoryID, $categoryName, $prevoffset, $current-1, $i-1);
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
if($current==$i)
{
print("<font size=\"5\" color=\"#FF0000\"><b>$i </font></b>");
}
else
{
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s\">$i</a> \n", $categoryID, $categoryName, $newoffset, $i);
}
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
$newoffset=$offset+$limit;
}
if($newoffset >= $numrows)
{
print(" ");
}
else
{
printf("<a href=\"$PHP_SELF?categoryID=%s&categoryName=%s&offset=%s¤t=%s&i=%s\">NEXT</a><p>", $categoryID, $categoryName, $newoffset, $current+1, $i+1);
}
?>
[/code]