Here is a strange one. I have variables that I wish to add together.
[php]
($subtotal + $delprice)
[/php]
For example
If $subtotal = 10 and $delprice = 10.50 When I add them together I get 10.50! Which is strange. What could be the issue. Its the same on all my sums.
Heres the full code:
[php]
<?php
$sqlequ="SELECT * FROM job_items WHERE job_id = '$id'";
$resultequ = mysql_query($sqlequ);
?>
<table id="invoiceitems" class="gridtable">
<thead>
<tr>
<th><strong>Product ID</strong></th>
<th><strong>Description</strong></th>
<th><strong>Cost</strong></th>
<th><strong>Qty</strong></th>
<th><strong>Nett</strong></th>
<th><strong>VAT</strong></th>
<th><strong>Gross</strong></th>
</tr>
</thead>
<tbody>
<tr class="noborder">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
$subtotal = '0';
$vattotal = '0';
$grand = '0';
while($rowequ = mysql_fetch_array($resultequ)){
?>
<tr>
<td><?php echo $rowequ['product_id']; ?></td>
<td><?php echo $rowequ['description']; ?></td>
<td><?php echo $site_settings['currency'].$rowequ['unit_price']; ?></td>
<td><?php echo $rowequ['quantity']; ?></td>
<td><?php echo $site_settings['currency'].$rowequ['before_vat']; ?></td>
<td><?php echo $site_settings['currency'].$rowequ['vat']; ?></td>
<td><?php echo $site_settings['currency'].$rowequ['subtotal']; ?></td>
</tr>
<?php
$subtotal = $subtotal + $rowequ['before_vat'];
$vattotal = $vattotal + $rowequ['vat'];
$grandtotal = $vattotal + $subtotal;
}
?>
</tbody>
<tfoot>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<?php
$delprice = $row['delprice'];
$delvat = ($delprice * ($site_settings['taxrate']/100));
?>
<td><strong>Delivery</strong></td>
<td><?php echo $row['deliver'];?></td>
<td> </td>
<td> </td>
<td><?php echo $site_settings['currency'].$delprice;?></td>
<td><?php echo $site_settings['currency'].number_format($delvat, 2, '.', '');?></td>
<td><?php echo $site_settings['currency'].number_format(($delprice + $delvat), 2, '.', '');?></td>
</tr>
<tr>
<td> </td>
<td><strong>Subtotal:</strong></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><?php echo $site_settings['currency'].number_format(($subtotal + $delprice), 2, '.', '');?></td>
</tr>
<tr>
<td> </td>
<td><strong>Vat total:</strong></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><?php echo $site_settings['currency'].number_format(($vattotal + $delvat), 2, '.', '');?></td>
</tr>
<tr>
<td> </td>
<td><strong>Grand total:</strong></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><?php echo $site_settings['currency'].number_format(($grandtotal + $delprice + $delvat), 2, '.', '');?></td>
</tr>
</tfoot>
</table>
[/php]