Jump to content

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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.