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>'; } Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.