Since MS Access can't use the wonderful "LIMIT" in the SQL clause, this is what I've been working on. I get the first 10 records but nothing else.
<?PHP
if (!$conn = new COM("ADODB.Connection"))
exit("Unable to create an ADODB connection<br>");
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("database.mdb");
$conn->open($strConn);
if ($DESIGNERNAME == 'Any') {
$DESIGNERNAME = '%';
}
if ($SILHOUETTE == 'Any') {
$SILHOUETTE = '%';
}
if ($NECKLINE == 'Any') {
$NECKLINE = '%';
}
if(!isset($numrows)) $numrows = 0;
$strSQL2 = "SELECT * FROM tblINVENTORY WHERE designer LIKE '$DESIGNERNAME' AND silhouette LIKE '$SILHOUETTE' AND neckline LIKE '$NECKLINE' AND quantity > 0";
$rs2 = $conn->execute($strSQL2);
while (!$rs2->EOF) {
$numrows = $numrows + 1;
$rs2->MoveNext();
}
echo $numrows;
$i=0;
if(!isset($currentvalue)) $currentvalue = 0;
echo $currentvalue;
$strSQL = "SELECT TOP $numrows itemnumber, dressname, stylenumber, designer, silhouette, neckline, size, fabric, color, price, description, quantity FROM tblINVENTORY WHERE designer LIKE '$DESIGNERNAME' AND silhouette LIKE '$SILHOUETTE' AND neckline LIKE '$NECKLINE' AND quantity > 0 ORDER BY dressname";
$rs = $conn->execute($strSQL);
$ITEMNUMBER = $rs->Fields(0);
$DRESSNAME = $rs->Fields(1);
$STYLENUMBER = $rs->Fields(2);
$DESIGNER = $rs->Fields(3);
$SILHOUETTE = $rs->Fields(4);
$NECKLINE = $rs->Fields(5);
$SIZE = $rs->Fields(6);
$FABRIC = $rs->Fields(7);
$COLOR = $rs->Fields(8);
$PRICE = $rs->Fields(9);
$DESCRIPTION = $rs->Fields(10);
$QUANTITY = $rs->Fields(11);
while (!$rs->EOF && $i < $currentvalue) {
$i=$i + 1;
$rs->MoveNext();
}
$endvalue = $currentvalue + 10;
$startvalue = $currentvalue + 1;
while (!$rs->EOF && $startvalue <= $endvalue) {
print "<table width=60% border=1 cellpadding=2 cellspacing=0 bordercolor=#CCCCCC>";
print "<tr bgcolor=#000000> ";
print "<td width=0%>";
print "<p><img src=gownpics/$STYLENUMBER->value.jpg width=150 height=225 align=left><font size=2 face=Geneva, Arial, Helvetica, san-serif color=#FFFFFF><br>";
print "Gown Name: <a href=individualgown.php?itemnumber=$ITEMNUMBER->value&stylenumber=$STYLENUMBER->value>$DRESSNAME->value<br></a>";
print "Item Number: $ITEMNUMBER->value<br>";
print "Designer: $DESIGNER->value<br>";
print "Silhouette: $SILHOUETTE->value<br>";
print "Style Number: $STYLENUMBER->value<br>";
print "Fabric: $FABRIC->value<br>";
print "Size: $SIZE->value<br>";
print "Color: $COLOR->value<br>";
print "Neckline/Sleeve: $NECKLINE->value<br>";
print "Description: $DESCRIPTION->value</b></font></p>";
print "<p><font size=2 face=Geneva, Arial, Helvetica, san-serif color=#FFFFFF><b>Price: $PRICE->value</b> </font></p>";
print "</td>";
print "</tr>";
print "</table>";
$rs->MoveNext();
$startvalue = $startvalue + 1;
}
$rs->Close();
$rs2->Close();
$conn->Close();
$rs = null;
$rs2 = null;
$conn = null;
$previouspage = $currentvalue - 10;
$nextpage = $currentvalue + 10;
$currentvalue = $nextpage;
if($currentvalue > 10)
echo "<a href=\"availablegowns3.php?currentvalue=$previouspage&designer=$DESIGNER->value&silhouette=$SILHOUETTE->value&neckline=$NECKLINE->value\">Previous</a><BR>";
if($numrows > ($currentvalue))
echo "<a href=\"availablegowns3.php?currentvalue=$nextpage&designer=$DESIGNER->value&silhouette=$SILHOUETTE->value&neckline=$NECKLINE->value\">Next</a><BR>";
?>