i have this total from my first table (income) and I would want to subtract it from the another table(exp) query. All these code are on thesame page. So how can i use these query variables to subtract and echo result on thesame page but in another location? Query 1
<?php
include("db.php");
$query = "SELECT source, SUM(income.inamount) FROM income";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total Sales = N". $row['SUM(inamount)'];
echo "<br />";
}
?>
<?php
include("db.php");
$query = "SELECT amount, SUM(exp.amount) FROM exp";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total Expenditure = N". $row['SUM(amount)'];
echo "<br />";
}
?>