Total the result of 2 queries
Posted: Sat Jun 29, 2013 9:52 pm
Need to total results of 2 queries, have this, it works, but not sure if it is the correct way to do this?
Thanks in advance for any assistance
Code: Select all
<?php
$result1 = mysql_query('SELECT SUM(inv_paid_amount) AS total_paid FROM inv_to');
$row1 = mysql_fetch_assoc($result1);
$result2 = mysql_query('SELECT SUM(Paid)AS paid_member FROM members_fin');
$row2 = mysql_fetch_assoc($result2);
$sum = $row1['total_paid']+$row2['paid_member'];
echo "$ ".number_format($sum, 2);
?>