Jump to content

Sum from multiple tables


nerd99

Recommended Posts

Hi,

 

I'm trying to do a very simple calculation. I have two separate tables containing invoice information. I need to add the totals from all invoices and display them.

 

I need to add the sum of the following columns:

TABLE A: amount_received

TABLE B: total

 

Here's my starting point - I have the total from TABLE A. I have tried various other things but nothing is working for me. Where do I go from here?

 

<?php

$result = mysqli_query($connection,"SELECT SUM(amount_received) FROM table A ")or die(mysqli_error($connection));

// Print out result
while($row = mysqli_fetch_array($result)){

echo '<td>$'.$row['SUM(amount_received)'].'.00</td>';

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/211119-sum-from-multiple-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.