I am having a problem with this code it displays fine and seems to be working but it always drops the first record. If there should be 6 records it displays 5 the first one is allways missing.
If someone has a better way to do this please let me know
Thanks Carmine
<?php
$limit=20; // rows to return
$numresults=mysql_query("SELECT DISTINCT Production.QuoteNumber,Production.DocketNumber,Estimating.Customer,Estimating.Shipping,Estimating.JobName,Production.Quantity,Production.Status
FROM Production,Estimating
WHERE Estimating.DocketNumber=Production.DocketNumber
AND Production.Status='open'ORDER BY Customer");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=1;
}
$result=mysql_query("SELECT DISTINCT Production.QuoteNumber,Production.DocketNumber,Estimating.Customer,Estimating.Shipping,Estimating.JobName,Production.Quantity,Production.Status
FROM Production,Estimating
WHERE Estimating.DocketNumber=Production.DocketNumber
AND Production.Status='open'ORDER BY Customer LIMIT $offset,$limit");
// now you can display the results returned
while ($r = mysql_fetch_array($result)){
$DocketNumber = $r["DocketNumber"];
$Quantity = $r["Quantity"];
$Customer = $r["Customer"];
$JobName = $r["JobName"];
$Status = $r["Status"];
$QuoteNumber = $r["QuoteNumber"];
$Shipping = $r["Shipping"];
if (!$QuoteNumber) {
$Quote="<font color=\"#CC0000\" face=\"Arial, Helvetica, sans-serif\"><b>Add Quote !</b></font>";
}else{
$Quote= "$QuoteNumber";
}
echo"<table width=\"400\" cellpadding=\"4\" cellspacing=\"0\" bgcolor=\"#CCCCCC\" border=\"0\" align=\"center\">
<tr><td valign=\"middle\"><font face=\"helvetica\"><b>$Customer</b></font></td><td align=\"right\" valign=\"middle\">
<font face=\"helvetica\">
<a href=\"Production.php?DocketNumber=$DocketNumber\">Production</a>
</font>
</td></tr>
</table>
<table width=\"400\" cellpadding=\"4\" cellspacing=\"0\" bgcolor=\"#EEEEEE\" border=\"0\" align=\"center\">
<tr>
<dd>Docket Number : $DocketNumber Quote Number : $Quote
<dd>Job Name: <b>$JobName</b>
<dd>Quantity: $Quantity
<dd>Shipping : <font color=\"#CC0000\" face=\"Arial, Helvetica, sans-serif\"><b>$Shipping</b></font><br>
<dd>
</tr>
";
print" </table>";
}
// next we need to do the links to other results
if ($offset==1) { // bypass PREV link if offset is 0
$prevoffset=$offset-20;
print "<a href=\"$PHP_SELF?offset=$prevoffset\">PREV</a> \n";
}
// 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);
print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> \n";
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?offset=$newoffset\">NEXT</a><p>\n";
}
?>