blasterstudios
Technical User
How would I go about performing calculations such as multiplying to fields in the same row in my dynamic table?
here is some sample code:
the fields i want to multiply should be like this:
This calculation only does the first row, then repeats the result for the remaining rows.
here is some sample code:
Code:
<table width="660" border="0" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333" class="invdetails">
<tr bgcolor="#CCCCCC" class="invdetails">
<td class="invdetails"><span style="font-size: x-small; font-weight: bold">Product Name</span></td>
<td width="70" class="invdetails"><span style="font-size: x-small; font-weight: bold">Unit Price </span></td>
<td width="50" class="invdetails" style="font-size: x-small"><div align="center" style="font-weight: bold">Quantity</div></td>
<td width="90" class="invdetails"><span style="font-size: x-small; font-weight: bold">Per</span></td>
<td width="60" class="invdetails"><span style="font-size: x-small; font-weight: bold">Discount</span></td>
<td width="60" class="invdetails"><div align="right" style="font-weight: bold"><span style="font-size: x-small">Item Total </span></div></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php
if($SSAdv_m1%$SSAdv_change_every1==0 && $SSAdv_m1>0){
$SSAdv_k1++;
}
print $SSAdv_colors1[$SSAdv_k1%count($SSAdv_colors1)];
$SSAdv_m1++;
?>" class="invdetails">
<td class="invdetails"><span style="font-size: x-small"><?php echo $row_invoicedetails['productid']; ?></span></td>
<td width="70" class="invdetails"><span style="font-size: x-small"><span style="font-size: x-small">$<?php echo number_format($row_invoicedetails['itemprice'],2,'.',','); ?></span></span></td>
<td width="50" class="invdetails" style="font-size: x-small"><div align="center"><?php echo $row_invoicedetails['quantity']; ?></div></td>
<td width="90" class="invdetails"><span style="font-size: x-small"><?php echo $row_invoicedetails['per']; ?></span></td>
<td width="60" class="invdetails"><span style="font-size: x-small"><?php echo $row_invoicedetails['discount']; ?></span></td>
<td width="60" class="invdetails"><div align="right" style="font-size: x-small; font-weight: bold">$<?php echo $rowtotal; ?></div></td>
</tr>
<tr <?php
// technocurve arc 3 php bv block2/3 start
echo " style=\"background-color:$color\"";
// technocurve arc 3 php bv block2/3 end
?>>
<td colspan="6" class="invdetails"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%" align="center" valign="middle"><img src="images/notesarrow.gif" width="10" height="10"></td>
<td width="97%"><span style="font-size: x-small"><?php echo $row_invoicedetails['notes']; ?></span></td>
</tr>
</table> </td>
</tr>
<?php
// technocurve arc 3 php bv block3/3 start
if ($color == $color1) {
$color = $color2;
} else {
$color = $color1;
}
// technocurve arc 3 php bv block3/3 end
?>
<?php } while ($row_invoicedetails = mysql_fetch_assoc($invoicedetails)); ?>
</table>
Code:
$itemprice = $row_invoicedetails['itemprice'];
$quantity = $row_invoicedetails['quantity'];
$discount = (1 - $row_invoicedetails['discount']);
$rowtotal = (($itemprice * $quantity)*($discount));
This calculation only does the first row, then repeats the result for the remaining rows.