I would say do this in one query - much, much easier:
$query = 'SELECT year, SUM(count) AS total FROM (
SELECT year, count(*) AS count FROM table1 GROUP BY year
UNION
SELECT year, count(*) AS count FROM table2 GROUP BY year
) t GROUP BY year';
Then it's a simple matter of looping through the result set and building your arrays:
$years = $amounts = array();
while($row = mysql_fetch_assoc($exec)) {
$years[] = $row['year'];
$amounts[] = $row['total'];
}
EDIT: My example query uses a subquery, which itself is two queries UNION'ed together. What I'm getting at, is that I'm no SQL guru - there may be a more optimized way to do this, so if you have tons of data to sift through, you might want to ask around in the DB forum.