So assuming you know how to work with SQL in PHP, it's as simple as this:
// STOP USING mysql, use mysqli or PDO, for demonstration purposes only
$results = mysql_query('SELECT foo, bar, baz FROM table');
while ($row = mysql_fetch_assoc($results)) {
echo $row['foo'] - $row['bar'] * $row['baz'];
}
Assuming the columns are all numeric, that's all you need to do to subtract and multiply values from the database in PHP.