Do it all in 1 query with a LEFT JOIN is how this should be done - always assuming you have your data normalised properly. You can get also away with some GROUP BY coding shortcuts in mysql that will NOT work with most other db engines
$query = "SELECT gifts.gift_name, gifts.gift_id, SUM($octg$year.gift_order_total) AS totalsoctobergiftsgr, SUM($octg$year.gift_order_fmv) as totalsoctobergiftsfmvgr
FROM gifts LEFT JOIN $octg$year USING (gift_id)
WHERE gifts.gift_type = '$rev' AND $octg$year.member_profile_id ='$col' AND $octg$year.status = '$stats'
GROUP BY $octg$year.gift_order_total, $octg$year.gift_order_fmv
ORDER BY gifts.gift_name";
Now, the resulting NULL values that you will get for the $octg$year columns when there is no match in that table are what you test for in your php code when generating the html output, ie
if (isnull($row['totalsoctobergiftsgr'])) {
echo '0.00';
} else {
echo $row['totalsoctobergiftsgr'];
}