PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Even if the two tables are linked in some way, I don't think there's going to be any real advantage in trying to retrieve both totals in the same query so what you're doing is probably correct. However, if you're running this query very often, you could add a separate column to each table that you increment whenever any invoices are paid - this would mean that your script would only have to retrieve a single value, not sum the values of all invoices in the database each time.