Thanks but I still can't get it to work.
Here is some additional code:
//result 2 gets distinct records
while ($row=mysql_fetch_array($result2)) {
$pin_batchid=$row["batchid"];
$retail=$row["pinvalue"];
$decrement=$row["decrement"];
$resell=$row["resell"];
//get the total number of pins activated within each batch
$result3=mysql_query("SELECT COUNT(username) as counter FROM pins WHERE batchid='$pin_batchid'AND (pins.firstlogin>='$datefrom' AND firstlogin<='$dateto') AND currency='$currency'");
while ($row=mysql_fetch_array($result3)) {
$numpins=$row["counter"];
$due=(($retail/$decrement)($resell$numpins));
$amount_due=round($due,2);
}
Now I need to sum the $amount_due for each record.
Is that any clearer? or perhaps you don't need clarification and I do. 🙂