nerd99 Posted August 18, 2010 Share Posted August 18, 2010 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 More sharing options...
Pikachu2000 Posted August 18, 2010 Share Posted August 18, 2010 Start by copy/pasting the query into phpMyAdmin and seeing if it runs successfully that way. Link to comment https://forums.phpfreaks.com/topic/211119-sum-from-multiple-tables/#findComment-1100998 Share on other sites More sharing options...
nerd99 Posted August 18, 2010 Author Share Posted August 18, 2010 Ok, thanks. I've sorted it out. I just need to define the totals separately then add them! Link to comment https://forums.phpfreaks.com/topic/211119-sum-from-multiple-tables/#findComment-1101000 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.