Jump to content

Math: Add fields of database


ririe44

Recommended Posts

I'm having a hard time getting any good results by asking what I'm asking... because everyone has already asked how to "add" a row or field to a "database". 

 

So, anyway... How do I go about adding all the fields in a certain column of my database?  It's obviously money, so I have:

 

table name=amounts

categoryamount

cat156.85

cat2101.94

total?? ?? ??

 

Any help will be awesome, thanks!

Link to comment
https://forums.phpfreaks.com/topic/147779-math-add-fields-of-database/
Share on other sites

hmm... okay, this is what I've put into my code...

 

$exp_total = mysql_query("SELECT SUM(amount) FROM $tbl_name") or die(mysql_error());

 

Then, where I display this:

Print "<td>Total Expenses</td> <td colspan=2 align=right>".$exp_total."</td>";

 

My result says "Resource id #4", where I was expecting a number... any thoughts?

 

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.