Hey dude, don't quite understand what you're saying (apologies, still learning!). My code is below. If I remove , SUM(vat) AS 'vat' from the query everything works perfectly but I need to calculate the VAT but it doesn't appear to be working - I have already calculated the VAT before it enters the database, I'm just adding all the rows up.
PHP Code:
function dupSub(){
$query = mysql_query("SELECT SUM(sub_total) AS 'block', SUM(vat) AS 'vat' FROM order_products WHERE receipt_id='$_GET[ref]'");
$query = mysql_fetch_array($query);
$delivery = mysql_query("SELECT * FROM orders WHERE receipt_id='$_GET[ref]'");
$delivery = mysql_fetch_array($delivery);
//Get Grand Total Result
$tots = number_format($query['block']-$delivery['part_exchange']+$delivery['delivery_costs'],2);
echo 'Order Subtotal £'.number_format($query['block'],2).'<br/>
Delivery £'.$delivery['delivery_costs'].'<br/>';
if ($delivery['part_exchange']>0.00){
echo 'Part Exchange Value: £'.$delivery['part_exchange'].'<br/>
<b>Grand Total: £'.$tots.'</b><br/>
<b>VAT Amount:</b> £'.$query['vat'].'
';
}
else {
echo '<b>Grand Total: £'.$tots.'</b><br/>
<b>VAT Amount:</b> £'.$query['vat'].'
';
}
}
** I know I need to secure the queries instead of using $_GET **
Bookmarks