php一个sql查询和一个php变量

Hey guys i want a sum of an mysql query and an php variable. Is there a function to do this? Here is what i tried:

$result3 = mysql_query($sql3);
                while ($resultarray3 = mysql_fetch_array($result3)){
                $Ergebnis = $Menge + $resultarray['Bestand'];
                echo $Ergebnis;
                }

Can anyone help me on this?

Edit: I want a sum of an php variable and an mysql query not of two sql tables!!!!

$menge = '';
$result3 = mysql_query($sql3);
while ($resultarray3 = mysql_fetch_array($result3)){
  $menge = $menge + $resultarray3['Bestand'];
}
// result => $menge

A query to show a result contains SUM(column), so you could use:

$sql3 = "SELECT bestand, SUM(bestand) as menge FROM database GROUP BY bestand";

And then in PHP

$result3 = mysql_query($sql3);
while ($resultarray3 = mysql_fetch_array($result3)){
    echo $resultarray['bestand'] . ' = ' . $resultarray['menge'];
}

If there is only one row you don't need the .=

$result3 = mysql_query($sql3);
            while ($resultarray3 = mysql_fetch_array($result3)){
            $Ergebnis .= $Menge + $resultarray3['Bestand'];//notice the change on this line
            echo $Ergebnis;
            }

You define $resultarray3 but then you use $resultarray without the three.

$Ergebnis = $Menge + $resultarray3['Bestand'];